Grab the Free VBA Quick Reference Guide
[ Ссылка ]
In this video we use a nice little piece of code that will find all of the files within a folder and all of its subfolders.
A Subscriber requested this video as he was reminiscing of ages gone by when Excel 2003 had a file search function
NOTE: Since this is pulling all the folder and subfolders it could take a lot of time and return a bunch of files
CODE:
==============
Sub Find_Files()
Dim fldr As FileDialog
Set fldr = Application.FileDialog(msoFileDialogFolderPicker)
fldr.Show
f = fldr.SelectedItems(1)
f = f & "\"
ibox = InputBox("File Must Contain (Note * wildcards can be used)", , "*.xls*")
On Error GoTo ext
sn = Split(CreateObject("wscript.shell").exec("cmd /c Dir """ & f & ibox & """ /s /a /b").stdout.readall, vbCrLf)
Sheets(1).Cells(1).Resize(UBound(sn) + 1) = Application.Transpose(sn)
ext:
End Sub
Ещё видео!