I have a sheet with just one table. As of right now, the table is named "Main", but it will get changed later (working with queries).
Here is a test function that checks for a certain set of values within two columns of the table:
Is there a way to modify my code so that I don't have to include the table name? I don't want to have to go to my VBA code and change every instance of the name if I were to change the table name again in the future.
Note: The sub which calls the above function will activate the sheet that "Main" is on before calling the function.
Here is a test function that checks for a certain set of values within two columns of the table:
VBA Code:
Function testFunc(ByVal a As String, ByVal b As String) As Boolean
Dim tb
Dim i As Long
tb = ActiveSheet.ListObjects("Main").DataBodyRange.Resize(, 3)
For i = 1 To UBound(tb, 1) 'for each row in table,
If tb(i, 2) = a Then 'check col 2 for a
If tb(i, 3) = b Then 'check col 3 for b
testFunc = True
Exit Function
End If
End If
Next
End Function
Is there a way to modify my code so that I don't have to include the table name? I don't want to have to go to my VBA code and change every instance of the name if I were to change the table name again in the future.
Note: The sub which calls the above function will activate the sheet that "Main" is on before calling the function.