Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time error '91: Object variable or with block variable not set 2

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Good afternoon. I have spreadsheets with multiple worksheets and my user wants to search for certain names. I start off with this
Code:
 MyText = InputBox("Type the text for the rows you want to cut.", "Look for this")

And get down to
Code:
  Range("E:E").Find(What:=MyText, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False).Activate

The trouble is that it falls over at the second consecutive worksheet where nothing matches the find. I've tried a couple of
Code:
 If ....Then
to trap & move on but it fails on the first loop (the first 'Find') of the second sheet where nothing matches.

Any ideas?

Many thanks,

Des.
 
Well,
Code:
 On Error Resume Next
but not 'Resume' within this context.

Des.
 
Combo, FYI, Resume is the only way, aside from exiting the procedure, to get out of an error handling block, dot.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top