obviously not tested
Sub FindInSubfolders() ' main, call SubFoldersFind
Dim StrFile As String, objFSO, destRow As Long, fname As String
Dim mainFolder, mySubFolder
mFolder = Range("B2").Value
fname = Range("B3").Value
macroname = Range("B4").text
mdata = Range("B5").text
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set mainFolder = objFSO.GetFolder(mFolder)
StrFile = Dir(mFolder & "\" & fname)
If StrFile <> "" Then
Workbooks.Open mFolder & "\" & StrFile
Else
SubFoldersScan OfFolder:=mainFolder, fname:=fname
End If
Range("A1").value = mdata
nn = ActiveWorkbook.Name
Application.Run "'" & nn & "'!" & macroname
End Sub
Sub SubFoldersScan(OfFolder As Variant, fname As String)
Dim SubFolder
For Each SubFolder In OfFolder.SubFolders
StrFile = Dir(SubFolder & "\" & fname)
If StrFile <> "" Then
Workbooks.Open SubFolder & "\" & StrFile
Exit For
End If
SubFoldersScan OfFolder:=SubFolder, fname:=fname
Next SubFolder
End Sub
Bookmarks