To chaju: Help with searching all sheets for value.

Tom Urtis

MrExcel MVP
Joined
Feb 10, 2002
Messages
11,300
Chaju:

Regarding your post at
http://www.mrexcel.com/board/viewtopic.php?topic=7742&forum=2&1 --

I'm responding to you this way because your subject line only contains the word "Help!", which does not give the board's readers an indication of what the actual topic is.

Just a friendly suggestion, it's a good practice to provide a consise description in the subject line, maybe such as (in your case) "How to search all sheets for value?". This will improve your chances for a reply, and save other board browsers some time in reading (or skipping over) your topic.

As for a possible solution, if I understand your question correctly, try a macro like this:

Sub SearchAllSheets()
Dim sVal
Dim counter As Integer, sheetCount As Integer
Dim bSh, bCell
Application.ScreenUpdating = False
On Error Resume Next
bCell = ActiveCell.Address
bSh = ActiveSheet.Name
sVal = InputBox("Please enter the value you want to locate:", "What are you looking for?")
If sVal = "" Then
MsgBox "Please click OK to return from whence you came.", 64, "Search cancelled."
Exit Sub
Else
If IsError(CDbl(sVal)) = False Then sVal = CDbl(sVal)
sheetCount = ActiveWorkbook.Sheets.Count
counter = 1
Do Until counter > sheetCount
Sheets(counter).Activate
Cells.Find(What:=sVal, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
If ActiveCell.Value = sVal Then Exit Do
counter = counter + 1
Loop
If ActiveCell.Value <> sVal Then
MsgBox "The value you entered could not be found." & vbCrLf & _
"Please click OK to get back into the workbook.", 64, "Sorry..."
Application.Goto Reference:=Worksheets(bSh).Range(bCell)
Application.ScreenUpdating = True
Exit Sub
End If
End If
Application.ScreenUpdating = True
End Sub

Hope this helps.
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top