A robust file-walker that opens each workbook read-only, appends rows into a consolidated sheet, and handles errors per file so a single bad workbook never breaks the run.
Syntax-highlighted VBA — first 14 lines unlocked. Upgrade to view the full project.
1Option Explicit23' Folder Processor — recursively iterate every file in a folder and4' consolidate its data into a single workbook.56Public Sub ProcessFolder()7 Dim folderPath As String, filePath As String8 Dim src As Workbook, dst As Worksheet9 Dim nextRow As Long1011 folderPath = SelectFolder()12 If Len(folderPath) = 0 Then Exit Sub1314 Set dst = ThisWorkbook.Worksheets("Consolidated")15 dst.Cells.Clear16 dst.Range("A1:E1").Value = Array("Source", "Date", "Category", "Amount", "Notes")17 nextRow = 21819 filePath = Dir(folderPath & "\*.xlsx")20 Do While Len(filePath) > 021 Application.ScreenUpdating = False22 Set src = Workbooks.Open(folderPath & "\" & filePath, ReadOnly:=True)23 nextRow = AppendSheetRows(src.Worksheets(1), dst, nextRow, filePath)24 src.Close SaveChanges:=False25 Application.ScreenUpdating = True26 filePath = Dir()27 Loop2829 MsgBox nextRow - 2 & " rows consolidated.", vbInformation30End Sub
Unlock XLFormula AI Pro to view the complete project source, download the .xlsm workbook, and generate custom VBA with AI.
Unlock with ProEvery download, every VBA project, every future release for $5.00/month.
Mail-merge personalised emails with per-row attachments, rate limiting, and delivery logging.
Categorise transactions, roll up totals, and refresh a live budget dashboard with one macro.
Refresh every PivotTable and chart, then export a snapshot PNG for the daily report.