I would like to loop through folder that contains multiple subfolders to find excel files that contain specified name, and do stuff with those found excel files. Any suggestions how can I achieve that?
I have found something like this but it's not working:
Application.ScreenUpdating = False
Application.DisplayAlerts = False
With Application.FileSearch
.NewSearch
.LookIn = "C:\temp 1" ' your drive / directory here
.SearchSubFolders = True
.FileName = ".xls" ' all files ending in xls
.FileType = msoFileTypeExcelWorkbooks
If .Execute() > 0 Then
' how many files are there in the selected folder?
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
Workbooks.Open .FoundFiles(i), 0
'
' code
'
'
ActiveWorkbook.Save
ActiveWorkbook.Close
Next i
Else
MsgBox "There were no files found."
End If
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "All Done!"