XXLFormula AI
Pro ProjectAutomationAdvancedIncludes .xlsm

Folder Processor

4.7· 2,140 learners

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.

Learners
2,140
Duration
4 hours
Difficulty
Advanced
Folder Processor.xlsm — VBA EditorFileEditViewInsertFormatDebugRunToolsAdd-InsWindowHelpRun Sub/UserForm (F5)Project — VBAProjectVBAProject (Budget Automation.xlsm)Microsoft Excel ObjectsSheet1 (Transactions)Sheet2 (Dashboard)Sheet3 (Settings)ThisWorkbookFormsfrmCategoryEditorModulesmodBudgetmodChartsmodUtilsClass ModulesclsTransactionProperties — modBudget(Name)modBudget(General) ▾    RefreshBudget ▾1Option Explicit23' Budget refresh — one-click month-end.4Public Sub RefreshBudget()5    Dim wsData As WorksheetwsDash As Worksheet6    Dim lastRow As Longi As Long78    On Error GoTo Fail9    Application.ScreenUpdating = False1011    Set wsData = ThisWorkbook.Worksheets("Transactions")12    Set wsDash = ThisWorkbook.Worksheets("Dashboard")13    lastRow = wsData.Cells(wsData.Rows.Count"A").End(xlUp).Row1415    For i = 2 To lastRow16        Call AddToCategory(wsDash_17            CStr(wsData.Cells(i"C").Value), _18            CCur(wsData.Cells(i"D").Value))19    Next i2021    Application.ScreenUpdating = True22    MsgBox "Budget refreshed."vbInformation23    Exit Sub24Fail:25    Application.ScreenUpdating = True26    MsgBox "Failed: " & Err.DescriptionvbCritical27End SubImmediate — runningRefreshBudget?RefreshBudget › Loaded 218 transactions from 'Transactions' › Categories matched: 12 / 12 › Savings goals recalculated (6 goals) › Trend chart rebuilt in 42 ms Done. 0 errors, 0 warnings.ReadyLn 24, Col 5

Project screenshots

Code preview

Syntax-highlighted VBA — first 14 lines unlocked. Upgrade to view the full project.

folder-processor.bas
VBA
1Option Explicit
2 
3' Folder Processor — recursively iterate every file in a folder and
4' consolidate its data into a single workbook.
5 
6Public Sub ProcessFolder()
7 Dim folderPath As String, filePath As String
8 Dim src As Workbook, dst As Worksheet
9 Dim nextRow As Long
10 
11 folderPath = SelectFolder()
12 If Len(folderPath) = 0 Then Exit Sub
13 
14 Set dst = ThisWorkbook.Worksheets("Consolidated")
15 dst.Cells.Clear
16 dst.Range("A1:E1").Value = Array("Source", "Date", "Category", "Amount", "Notes")
17 nextRow = 2
18 
19 filePath = Dir(folderPath & "\*.xlsx")
20 Do While Len(filePath) > 0
21 Application.ScreenUpdating = False
22 Set src = Workbooks.Open(folderPath & "\" & filePath, ReadOnly:=True)
23 nextRow = AppendSheetRows(src.Worksheets(1), dst, nextRow, filePath)
24 src.Close SaveChanges:=False
25 Application.ScreenUpdating = True
26 filePath = Dir()
27 Loop
28 
29 MsgBox nextRow - 2 & " rows consolidated.", vbInformation
30End Sub
Locked preview

Unlock XLFormula AI Pro to view the complete project source, download the .xlsm workbook, and generate custom VBA with AI.

Unlock with Pro

Key features

  • Recursive folder walker
  • Per-file error isolation
  • Consolidated output with source column
  • Progress log in the Immediate Window
  • Read-only opens — never mutates source files

What's included

  • Folder Processor.xlsm
  • Sample source folder with 12 workbooks
  • Setup guide (PDF)
Included with Pro

Get this project — and every other one

Every download, every VBA project, every future release for $5.00/month.

  • AI VBA Generator
  • Download Projects
  • Complete VBA Library
  • Lifetime Updates
  • Premium Templates
  • Priority Support

Frequently asked questions

How large a folder can it handle?
It's been tested on 500+ workbooks. For very large runs, disable ScreenUpdating (already on by default).

Related projects