variable not set

  • Thread starter Thread starter RaulDR
  • Start date Start date
R

RaulDR

Hi all,

I have this, it returns the error "variable not set"

Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

Application.Cells.Find(What:=sSearch, After:=ActiveCell,
LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


thanks so much in advance!
 
Hi,

There's nothing wrong with that snippet of code, your problem must lie in
another part. Post all the code.

Mike
 
You search string may be missing. Try this

Sub Mac()

Dim rngTemp As Range
Dim sSearch As String

sSearch = InputBox("Enter String to Search", "Search")

On Error Resume Next
Set rngTemp = Application.Cells.Find(What:=sSearch,
After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False)

On Error GoTo 0
If Not rngTemp Is Nothing Then Application.Goto rngTemp, True

End Sub

If this post helps click Yes
 
Is it perhaps that Option Explicit is set and you have incorrectly delcared
the variable? Or not at all?
 
Hi Jacob,

Thank you so much for your reply, my problem now is how to move the cursor
to the cell that match the "find"

Regards,
RackDr
 
I see, the variable not set error appear because Im trying to search a string
in a group of worksheet. Using ctrl-f you can search a string in a group of
worksheet how can I do that in vba?
 
Back
Top