General information
Title:
Seaching for a variable within worksheets
Hi.
I am trying to write a routine which will search for a user defined variable within an excel spreadsheet. I can set a variable to 'er' for example and the following code works (starting on sheet 1 and working through to sheet 'x'). But if I change the variable to 'stock' for example then the routine works over several sheets then breaks with 'Runtime error 91 - Object variable or with block variable not set'
Can anyone help please? (thanks)
Here is an extract of the code ---
For i = 1 To Sheets.Count
Title = "Currently Searching on TAB - " & Sheets(i).Name
Worksheets(i).Activate
Range("A1").Activate
Response = vbYes
While Response = vbYes 'Look for Variable
Cells.Find(What:=PAE, After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False) _
.Activate
Response = MsgBox(Msg, Style, Title, Help, Ctxt) 'Display message
Wend
Next i
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only