excel 2007 vba
i have a function that is supposed to look for a string in a range but i keep getting errors so here it is.
i get obj variable or with blk variable not set error
with this line of code
i have a function that is supposed to look for a string in a range but i keep getting errors so here it is.
Code:
Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As Variant, _
Optional LookAt As Variant, _
Optional MatchCase As Boolean) As Range
Dim c As Range, FirstAddress As String '<<
If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
If IsMissing(LookAt) Then LookAt = xlPart 'xlWhole
If IsMissing(MatchCase) Then MatchCase = False
With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _
SearchFormat:=False)
If Not c Is Nothing Then
Set Find_Range = c
FirstAddress = c.Address
Do
Set Find_Range = Union(Find_Range, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Function
with this line of code
Code:
Find_Range("Only", Columns("H"), xlFormulas, xlWhole).EntireRow.Copy Sheets("FHA'S W IMAGE").Range("A1")