I keep getting that error when I'm running my macro. When I debug, it points me to the bolded line in the code below.
The larger macro I'm running this function in runs this function some 101 times without error before this happens.
The values of the parameters are as follows when it gives me the error:
Find_Exact("hchen", ws1, "B:B")
The first parameter is the only one that changes in the previously mentioned running of this function.
What could possibly be the problem??![]()
Function Find_Exact(ByVal sText As String, ByRef ws As Worksheet, ByVal sRange As String) As Range Dim first_addr As Range Dim found_addr As Range Set first_addr = ws.Range(sRange).Find(sText, LookIn:=xlValues) If Not first_addr Is Nothing Then If ws.Cells(first_addr.Row, first_addr.Column) = sText Then Set Find_Exact = first_addr Else Do Set found_addr = ws.Range(sRange).FindNext(sText) If Not found_addr Is Nothing Then If ws.Cells(found_addr.Row, found_addr.Column) = sText Then Set Find_Exact = found_addr Exit Do End If End If Loop While Not found_addr Is Nothing And found_addr <> first_addr End If End If End Function
Thanks for the help.
Bookmarks