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
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