Im getting an invalid use of property error on the line where I try to assign the formatted table name to tables. I'm assuming this is a syntactical issue. However, I'm not sure what I want to do is possible without more code or different code. I want to grab the tablename of the activesheet so that in the next line it can be added in the range to create formatted table syntax(i.e. MyTable[EntityID])
Option Explicit
Private Sub Workbook_Open()
Dim ws As Worksheet
Dim wbkCurBook As Workbook
Dim searchValue As String
Dim searchSheet As String
Dim tableMatch As Range
Dim cell As Range
Dim combined As String
Dim x As Long
Dim LastColumn As Long
Dim tables As ListObject
Application.ScreenUpdating = False
Set wbkCurBook = ActiveWorkbook
'highlight all entityIDs with missing definitions
For x = 3 To Sheets.Count
Sheets(x).Activate
ws = ActiveSheet
tables = Sheets(x).ListObjects
For Each cell In Sheets(x).Range(tables & "[EntityID]")
searchValue = cell.Value
searchSheet = Sheets(x).Name
combined = searchSheet & " " & searchValue
With wbkCurBook.Sheets("Data Dictionary").Range("Dictionary[CombinedName]")
Set tableMatch = .Find(What:=combined, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If tableMatch Is Nothing Then
cell.Interior.Color = RGB(255, 0, 0)
End If
End With
Next cell
Next x
Application.ScreenUpdating = True
End Sub