I have the following function:
This stops on the line:
Set ResultRange = WkBook.Worksheets("Sheet1").Range(SearchRange).Find(SearchString)
It doesn't throw any errors just seems to exit the code and gives a #VALUE error.
Can anyone see anything obvious?
Thanks
Matt
Code:
Public Function FINDDATA(SearchString As String, FilePath As String, SearchRange As String, ColOffset As Integer, _
RowOffset As Integer) As Variant
Dim WkBook As Workbook
Dim ResultRange As Range
Set WkBook = Workbooks.Open(FilePath, True, True)
Set ResultRange = WkBook.Worksheets("Sheet1").Range(SearchRange).Find(SearchString)
If ResultRange Is Nothing Then
FINDDATA = "#REF!"
Else
Set FINDDATA = WkBook.Worksheets("Sheet1").Range.Find(SearchString).Offset(ColOffset, RowOffset).Value
End If
End Function
This stops on the line:
Set ResultRange = WkBook.Worksheets("Sheet1").Range(SearchRange).Find(SearchString)
It doesn't throw any errors just seems to exit the code and gives a #VALUE error.
Can anyone see anything obvious?
Thanks
Matt