Sub SearchAllSheets()
Dim ws As Worksheet
Dim rg As Range
Dim FindText As String
FindText = Application.InputBox("Please enter the address or named range you want to find")
For Each ws In ActiveWorkbook.Worksheets
Set rg = Nothing
Set rg = Find_Range(FindText, ws.Cells, xlFormulas, xlPart, False)
If Not rg Is Nothing Then
ws.Activate
rg.Select
End If
Next
End Sub
'Find_Range written by Aaron Blood
Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As XlFindLookIn = xlValues, _
Optional LookAt As XlLookAt = xlPart, _
Optional MatchCase As Boolean = False) As Range
Dim c As Range, FirstAddress As String
With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _
SearchFormat:=False) 'Delete this term for XL2000 and earlier
If Not c Is Nothing Then
Set Find_Range = c
FirstAddress = c.Address
Do
Set Find_Range = Union(Find_Range, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> FirstAddress
End If
End With
End Function
|