View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Search all sheets

Put it in a general module of Personal.xls or other workbook that will be
open

Sub FindAll()
Dim sh As Worksheet
Dim rng As Range
Dim sStr As String
sStr = InputBox("Enter item to search for")
If sStr = "" Then
MsgBox "You hit cancel"
End If
For Each sh In ActiveWorkbook.Worksheets
Set rng = sh.Cells.Find(What:=sStr, _
After:=sh.Range("A1"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
firstAddress = rng.Address
Do
If Not rng Is Nothing Then
Application.Goto rng, True
MsgBox "Hit key to continue"
End If
Set rng = sh.Cells.FindNext(rng)
Loop Until rng.Address = firstAddress
End If
Next
End Sub

I have changed ThisWorkbook to ActiveWorkbook.

--
Regards,
Tom Ogilvy


"Steve Wylie" wrote in message
...
Ah - I know what I was doing wrong. As per usual, I put the macro into

one
workbook spreadsheet on its own, then called up my workbook I wanted to

work
on and played the macro. The macro only searches the workbook that it is
recorded in. It will activate from another open workbook, but will only
search the workbook it is recorded in.

Does this mean I must record it on every workbook I need to search

through,
or can the macro be amended to search the workbook currently having focus?
Or is there a way I should "add-in" the macro workbook into the one that
contains the data?

Steve