I need to amend a column heading in multiple excel files. The files are located in subfolders two levels below the folder I want to loop through (28 .xlsx files in each folder, one folder for each Period).
The file structure is: "c:\...filepath...\Period *\Daily Attributions\*.xlsx"
I have managed to get some code to work that loops through each file in a folder but I need help to repeat the same loop for all the files in each folder.
Here's what I have so far.
Sub FirstLast()
'
' FirstLast Macro
'
Dim sPath As String
Dim sFile As String
Dim wb As Workbook
sPath = "C:\...filepath...\Period 1\Daily Attributions\"
sFile = Dir(sPath & "*.xlsx")
Do While sFile <> ""
Set wb = Workbooks.Open(sPath & sFile, UpdateLinks:=False)
Range("E1").Select
ActiveCell.FormulaR1C1 = "FirstLast"
ActiveWorkbook.Save
ActiveWindow.Close
sFile = Dir
Loop
End Sub