Search Excel Files and return value from found search

Chas17

Well-known Member
Joined
Oct 16, 2002
Messages
657
I use the code below to Searh other Excel Files in a specific dir for a match, I then ADD the Matched Files to a Listbox on a user form. I can then open these files if needed.

Two Qustions:
1. This works for TEXT, but how would I modify to search for a numeric value, integer?

2. Can the Location of the found matching Cell be identified so I can return its contents to the Active workbook?

Thanks,
Chas


With Application.FileSearch
.NewSearch
.LookIn = "H:\OSTD\Week 0 " & Range("SearchYear") & "\WWZ\"
.SearchSubFolders = True
.TextOrProperty = Range("SearchFor")
'.Filename = Criteria & "*.xls"
.FileType = msoFileTypeExcelWorkbooks 'msoFileTypeAllFiles
If .Execute(SortBy:=msoSortByFileName, _
SortOrder:=msoSortOrderAscending) > 0 Then
Range("SearchNumFiles") = .FoundFiles.Count
' MsgBox "There were " & .FoundFiles.Count & _
' " file(s) found."

For i = 1 To .FoundFiles.Count
' MsgBox .FoundFiles(i)
frmSearchResult.lstSearchResult.AddItem .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Any ideas?
I would like the location of the cell found for each File that produces a match.
THanks,
Chas
 
Upvote 0

Forum statistics

Threads
1,203,537
Messages
6,055,976
Members
444,839
Latest member
laurajames

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