ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Entire Workbook Search (https://www.excelbanter.com/excel-programming/373073-entire-workbook-search.html)

ArtLab

Entire Workbook Search
 
Is there any way to perform a "global" search or "lookup" of a given piece
of data in an entire workbook composed of several worksheets?? Any advise
will be greatly appreciated.

Art



Tom Ogilvy

Entire Workbook Search
 
Sub FindInWorkbook()
Dim rng as Range, sh as Worksheet
Dim vTarget as Variant, fAddr as String
vTarget = "dog"
For each sh in ActiveWorkbook.Worksheets
With sh.Cells
Set rng = .Find(vTarget, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not rng Is Nothing Then
fAddr = rng.Address
Do
msgbox rng.Address(0,0,xlA1,external:=True)
Set rng = .FindNext(rng)
Loop While rng.Address < fAddr
End If
End With
Next sh
End Sub

--
Regards,
Tom Ogilvy


"ArtLab" wrote in message
...
Is there any way to perform a "global" search or "lookup" of a given piece
of data in an entire workbook composed of several worksheets?? Any advise
will be greatly appreciated.

Art





All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com