My code is pretty simple, I am looking for a particular word in a column from a different worksheet. I made a "find" function to return True or false depending on whether or not it finds this word. The find function has two parameters, the particular column in the worksheet and the word it is looking for. See code below:
Public Function FoundExp(expID As String, ByVal lsCol As listColumn) As Boolean
Dim exp As String
Dim listCol As ListColumn
exp = expID
Set listCol = lsCol
FoundExp = Not lsCol.Range.find(exp) Is Nothing 'changed per BigBen <--error thrown here
End Function
When I call this function from another sub I get the error saying the object hasn't been set. Also, when I checked the datatype it comes out as a string.
This is the calling line:
Any idea on what I am doing wrong?
Edit: It might have something to do with the way I am instantiating the original listColumn that I am passing. I am calling the function from a separate sub, in this case in a different module, but the final position of the sub will on the same module as the find function.
Calling sub looks like:
Sub Foo()
Dim tbl2 as ListObject
Dim lsCol as ListColumn
Set tbl2 = ws.ListObjects.("TableName")
Set lsCol = tbl2.ListColumns(2)
Debug.Print lsCol 'this reads column header text
Debug.Print VarType(lsCol) 'this reads as 8
FoundExp "foo", lsCol
End Sub