I tried to search a value from another sheet rather using the .FIND function
Private Function Search(rng As Range, FindString As String) As Range
With rng
Set Search = .Find(what:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
End With
The funny thing is that if I enter
Search(Range("'DataSheet'!A1:Z1000"),"STARTING")
It works. When I try
SearchString = "'" & Selected_sheet &"'!A1:Z1000"
It does not work Selected_sheet is just a name of a worksheet (In this case, it is "DataSheet"). Using
Search(Range(SearchString ),"STARTING")
Error: RUN-TIME ERROR '91'
Object variable or With Block Varibale Not Set
What could be the actual problem?