Good morning, I am writing this code that allow me to open and copy a sheet in each macro file that I have in many subfolders. The problem is that I have all these files in subfolders included in a folder but they have all different names. What should I add to this code?
Thank you very much!
Application.EnableEvents = False
Application.ScreenUpdating = False
Path = ActiveWorkbook.Path
FileName = Dir(Path & "\*.xlsm", vbNormal)
Do Until FileName = ""
Set Wkb = Workbooks.Open(FileName:=Path & "\" & FileName, UpdateLinks:=3)
For Each ws In Wkb.Worksheets
Application.EnableEvents = False
Application.ScreenUpdating = False
wsName = ws.Name
If (wsName = "Summary (Output)") Then
ws.Copy After:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count)
Exit For
End If
Next ws
Wkb.Close False
FileName = Dir()
Loop
I don't have put all the declaration, but there are :)