Search multiple workbooks in file for data

  • Thread starter DJTI via OfficeKB.com
  • Start date
D

DJTI via OfficeKB.com

Is there a way to search multiple workbooks in a file with user input for
search then copying the data to another worksheet? Thank you in advance for
any help.
 
G

Guest

Something like this should work:
Sub SearchWorkbook()
Dim ws As Worksheet
Dim r As Range
Dim sSV As String 'Search Value
sSV = InputBox("Please Enter Search Value", "Searching...")
For Each ws In ActiveWorkbook.Worksheets
Set r = Nothing
Set r = ws.Cells.Find(What:=sSV, _
After:=ws.Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=True)
'Change LookAt:=xlWhole to xlPart if you want a partial match
If not r Is Nothing Then r.Copy 'Your Destination
Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top