I have tried to set up code to open up workbooks in a folders C:\extract as well as the sub-folders within C:\extract
I have set up the list of workbooks on sheet "Workspace"
When running the code only one of my workbooks in the sub-foldr open. Hoverver, If I copy the workbooks from the sub-folders into the folder C:\extract , then all the files open
It would be appreciated if someone could amend my code so that the files specified in workspace for eg BR1 ACCNTS (P) , BR2 ACCNTS (P) contained in the subfolder within C:\extract al open
I have set up the list of workbooks on sheet "Workspace"
When running the code only one of my workbooks in the sub-foldr open. Hoverver, If I copy the workbooks from the sub-folders into the folder C:\extract , then all the files open
It would be appreciated if someone could amend my code so that the files specified in workspace for eg BR1 ACCNTS (P) , BR2 ACCNTS (P) contained in the subfolder within C:\extract al open
Code:
Sub Open_Test()
Dim rngCell As Range
Dim zPATH As String: zPATH = "C:\extract\"
Dim FSO As Object: Set FSO = CreateObject("Scripting.FileSystemObject")
Dim FLD As Object: Set FLD = FSO.GetFolder(zPATH)
Dim SubFLDRS As Object: Set SubFLDRS = FLD.SubFolders
Dim SubFLD As Object
Dim wbData As Workbook
Application.ScreenUpdating = False
On Error Resume Next
For Each SubFLD In SubFLDRS
For Each rngCell In Range("A1:A" & Cells(Rows.Count, 1).End(xlUp).Row)
Set wbData = Workbooks.Open(zPATH & SubFLD.Name & "\" & rngCell.Value & ".xls")
Next rngCell
Next SubFLD
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub