Excel VBA

Excel VBA Macros

Copy-paste VBA macros for finance and accounting. Every snippet tested and explained.

Excel VBA Workbook Events: Complete Automation Series
Excel VBA
Series hub

Excel VBA Workbook Events: Complete Automation Series

The FinDataPro VBA series hub. 20 dedicated guides for Workbook_Open, BeforeClose, Worksheet_Change, loops, error handling, performance, and advanced automation. Every macro finance-tested.

Read Article
VBA Workbook_Open Event: Auto-Run a Macro When Excel Opens
Excel VBA
6 min read

VBA Workbook_Open Event: Auto-Run a Macro When Excel Opens

Use the VBA Workbook_Open event to run a macro automatically every time a file opens — force-refresh links to a shared bank statement folder with zero manual steps.

Read Article
VBA Workbook_BeforeClose Event: Stop Closing With Unsaved Work
Excel VBA
6 min read

VBA Workbook_BeforeClose Event: Stop Closing With Unsaved Work

Use Workbook_BeforeClose to block a reconciliation file from closing while it holds unposted entries — cancel the close, prompt to save, or force it, your choice.

Read Article
VBA Worksheet_Change Event: Fire Code When a Cell Updates
Excel VBA
6 min read

VBA Worksheet_Change Event: Fire Code When a Cell Updates

Use Worksheet_Change to auto-flag a cell red the moment a budget variance breaches threshold — no button, no macro to remember, it just runs.

Read Article
VBA Workbooks.Add: Create a New Workbook From Code
Excel VBA
6 min read

VBA Workbooks.Add: Create a New Workbook From Code

Use Workbooks.Add to spin up a new month-end working file from a template automatically — no manual File > New, no missed formatting.

Read Article
VBA GetOpenFilename: A File Picker Dialog for Your Macros
Excel VBA
6 min read

VBA GetOpenFilename: A File Picker Dialog for Your Macros

Use Application.GetOpenFilename to let a macro ask the user which bank statement CSV to import — no hardcoded file paths to break next month.

Read Article
VBA Protect Worksheet on Workbook Close: Re-Lock a Sheet Automatically
Excel VBA
6 min read

VBA Protect Worksheet on Workbook Close: Re-Lock a Sheet Automatically

Use Workbook_BeforeClose to re-apply sheet protection the moment a shared workbook closes — the other half of the unprotect-on-open pattern.

Read Article
VBA Close Workbook Without Saving: Skip the Save Prompt
Excel VBA
6 min read

VBA Close Workbook Without Saving: Skip the Save Prompt

Use Workbooks.Close SaveChanges:=False to batch-close month-end files without the save prompt — safe, deliberate, no data-loss risk.

Read Article
VBA Loop Through Worksheets: Build a Consolidated P&L
Excel VBA
6 min read

VBA Loop Through Worksheets: Build a Consolidated P&L

Use a For Each ws In Worksheets loop to pull data from every monthly tab into one consolidated sheet — one macro, one pass, zero copy-paste.

Read Article
VBA Check If Workbook Is Open: Prevent Duplicate-Open Errors
Excel VBA
6 min read

VBA Check If Workbook Is Open: Prevent Duplicate-Open Errors

Loop Application.Workbooks to check if a file is already open before your macro opens it again — stop duplicate-open errors on shared drives.

Read Article
VBA Loop Through Range of Cells: Flag Variance Outliers
Excel VBA
6 min read

VBA Loop Through Range of Cells: Flag Variance Outliers

Use a For Each cell In Range loop to test every cell in a budget-vs-actual sheet and flag variance outliers automatically.

Read Article
VBA Message Box Yes No: Confirm Before Posting Entries
Excel VBA
6 min read

VBA Message Box Yes No: Confirm Before Posting Entries

Use MsgBox with vbYesNo to build an approval gate before a macro posts journal entries — stop, confirm, and only proceed on Yes.

Read Article
VBA Find Last Row: End(xlUp) vs CurrentRegion vs UsedRange
Excel VBA
6 min read

VBA Find Last Row: End(xlUp) vs CurrentRegion vs UsedRange

Compare three ways to find the last row in VBA and which one breaks on ERP exports with blank rows.

Read Article
VBA Loop Through Files in a Folder: Batch-Import CSVs
Excel VBA
6 min read

VBA Loop Through Files in a Folder: Batch-Import CSVs

Use the Dir() function to loop through every file in a folder and batch-import bank statement CSVs into one workbook.

Read Article
VBA Copy Paste Values Only: Strip Formulas Before Archiving
Excel VBA
6 min read

VBA Copy Paste Values Only: Strip Formulas Before Archiving

Use PasteSpecial xlPasteValues, or the one-line .Value = .Value trick, to convert formula-driven schedules to static values.

Read Article
VBA Error Handling: On Error GoTo, Not Resume Next
Excel VBA
6 min read

VBA Error Handling: On Error GoTo, Not Resume Next

Why finance macros need On Error GoTo, not On Error Resume Next — a reconciliation macro that silently drops mismatches.

Read Article
VBA Array vs Range Performance: Timer-Tested on 50,000 Rows
Excel VBA
6 min read

VBA Array vs Range Performance: Timer-Tested on 50,000 Rows

Timer-tested: looping 50,000 rows via Range vs an array. The performance difference is not trivial.

Read Article
VBA Dictionary Object: Deduplicate a 10,000-Row AP Ledger
Excel VBA
7 min read

VBA Dictionary Object: Deduplicate a 10,000-Row AP Ledger

Use Scripting.Dictionary to deduplicate vendor names across a 10,000-row AP ledger in one pass — no library reference, no nested loops.

Read Article
VBA Export to PDF: Auto-Generate Individual Payslips
Excel VBA
7 min read

VBA Export to PDF: Auto-Generate Individual Payslips

Use ExportAsFixedFormat to auto-generate and save individual payslips or invoices as PDF, one file per row.

Read Article
VBA Send Email From Excel via Outlook: Auto-Email AR Aging
Excel VBA
7 min read

VBA Send Email From Excel via Outlook: Auto-Email AR Aging

Use late-bound CreateObject to send Outlook emails straight from Excel VBA — auto-email a customer-specific AR aging reminder.

Read Article
VBA UserForm Data Entry: A No-Training Expense Logging Form
Excel VBA
7 min read

VBA UserForm Data Entry: A No-Training Expense Logging Form

Build a VBA UserForm for expense data entry — no training required for non-finance staff, with validation before every submit.

Read Article