yippie_ky_yay
Board Regular
- Joined
- Jun 25, 2002
- Messages
- 63
Hello Forum,
I am using code found on this forum to do a search across all worksheets. This works great for the first instace of, but if I continue to search I get a "Object variable or With block variable not set" error. If I type in something that I know isn't in the workbook, it goes through most of the sheets and then I get "Unable to get the Find property of the Range class".
The code I am using is:
What = InputBox("Search for :")
If What = "" Then Exit Sub
For Each sht In Worksheets
sht.Activate
Set Found = sht.Cells.Find(What)
If Not Found Is Nothing Then
FirstAddress = Found.Address
Do
Found.Activate
Response = MsgBox("Continue?", vbYesNo + vbQuestion)
If Response = vbNo Then Exit Sub
Set Found = Cells.FindNext(After:=ActiveCell)
If Found.Address = FirstAddress Then Exit Do
Loop
End If
Next sht
MsgBox "Search Ended!"
I have yet to see the "Search Ended!" message pop up as I cannot get that far.
Any help would be greatly appreciated!
-Sean
I am using code found on this forum to do a search across all worksheets. This works great for the first instace of, but if I continue to search I get a "Object variable or With block variable not set" error. If I type in something that I know isn't in the workbook, it goes through most of the sheets and then I get "Unable to get the Find property of the Range class".
The code I am using is:
What = InputBox("Search for :")
If What = "" Then Exit Sub
For Each sht In Worksheets
sht.Activate
Set Found = sht.Cells.Find(What)
If Not Found Is Nothing Then
FirstAddress = Found.Address
Do
Found.Activate
Response = MsgBox("Continue?", vbYesNo + vbQuestion)
If Response = vbNo Then Exit Sub
Set Found = Cells.FindNext(After:=ActiveCell)
If Found.Address = FirstAddress Then Exit Do
Loop
End If
Next sht
MsgBox "Search Ended!"
I have yet to see the "Search Ended!" message pop up as I cannot get that far.
Any help would be greatly appreciated!
-Sean