Skip to content

Consulting, training and recruitment for organisations.

  • Dublin, Ireland
Automation

The Right Way to Build Macros in Finance

The macro is not the problem. The macro with no documentation, no owner, and no one who remembers why it does what it does — that is the problem.

Somewhere in your organisation right now, there is a workbook running a macro nobody wrote this year. It generates a report that goes to a senior committee. It works — mostly. Nobody is entirely sure what happens on the third Tuesday of a month-end that falls on a public holiday, because the person who knew left eighteen months ago and their replacement has been told not to touch it.

That is not a macro problem. That is a governance problem wearing a macro’s clothes.

When a macro is the right answer

VBA gets a harder time than it deserves. For a narrow class of problems — automating repetitive formatting tasks, generating templated outputs from structured data, processing fixed-schema inputs that arrive in the same format every month — a well-written Excel macro is a legitimate and practical solution. It requires no infrastructure, no deployment, no IT ticket. A competent analyst can build it, and a competent analyst can maintain it. That is not nothing.

The mistake is not using macros. The mistake is using them without the disciplines that any other piece of production code would demand.

The six rules of macro hygiene
Build it to survive without you
01 Name everything. Hard-coded cell references are where macros go to die. Range("C14") breaks the moment anyone inserts a row. Named ranges — defined once in the workbook and referenced consistently throughout — give the macro something stable to hold onto. If the data moves, you update the name, not every line of code that touches it. This is the single change that most extends the operational life of a macro.
02 Document the business logic, not just the code. Most macros in finance have comments that describe what the code does technically. What they rarely have is an explanation of why. Why is this figure divided by 252? Why does the loop skip the first row? Why is there a special case for entity codes beginning with “FX”? Business logic embedded in code without explanation becomes folklore within a year and mystery within three. Write a plain-English header block that explains the process being automated, the data it expects, and any rules it applies.
03 Keep a change log. Excel has no native version control. That is a fact of life, not an excuse for having no version history at all. A simple table at the top of the module — date, author, change made, reason — costs ten minutes and has saved many hours of forensic investigation when something breaks. If the workbook lives on SharePoint or a network drive, combine this with file-naming conventions that preserve prior versions. It is not elegant. It works.
04 Separate data from logic. A macro that reads from, processes, and writes to the same sheet is hard to test, hard to audit, and hard to modify safely. Where possible, keep source data on one sheet, outputs on another, and parameters — thresholds, dates, entity lists — on a clearly labelled configuration sheet. This means someone can review or modify the inputs without touching the code, and the code can be tested against known data without disturbing live outputs.
05 Balance future-proofing against over-engineering. There is a temptation, when building something used repeatedly, to anticipate every possible variation. Resist it. Build for the changes that are likely — a new column, an additional entity, a different output format — and document the assumptions you have made about what will not change. Over-engineered macros are harder to understand and maintain than simple ones. The goal is a macro that a capable analyst can read and modify in thirty minutes, not one that covers every edge case at the cost of legibility.
06 Ensure there is a backup person. Every macro running in a production context needs a named secondary owner — someone who understands what it does, where it lives, and how to intervene if it fails. This is not a technical requirement; it is an operational resilience requirement. Under frameworks like DORA, processes with single points of human failure are a risk to be managed, not a convenience to be tolerated. If only one person can explain the macro, the macro is already a liability.

A macro with documentation, named ranges, a change log, and two people who understand it is not a time bomb. It is a tool. The difference between the two is discipline, not technology.

Knowing when to move on

None of this makes VBA the right long-term answer for processes that grow in complexity, frequency, or regulatory visibility. The appropriate migration path — VBA to Python, Python to a proper data pipeline, or directly to an enterprise workflow tool — depends on the process, not on a general preference for newer tooling.

The trigger for migration is usually one of three things: the logic has become too complex to manage safely in a macro; the process is now running frequently enough to warrant proper monitoring and error handling; or the output is feeding something that regulators or auditors will scrutinise directly. When any of those conditions are met, the macro has done its job. Rebuild it properly.

The macros that cause operational incidents are rarely the ones someone built badly on purpose. They are the ones built sensibly, under time pressure, without the surrounding disciplines — and then inherited by people who had no context for them. That is a solvable problem. The solution is not to stop writing macros. It is to treat them with the same rigour you would apply to any other piece of code running in a production environment.

If you would not deploy an application without documentation, a change process, and a second person who understands it, you should not deploy a macro without those things either. The stakes are often identical.

Leave a Comment

Your email address will not be published. Required fields are marked *

All insights

Planning a change, reporting or regulatory project?

Tell us what you are working on and we will arrange a short call to talk it through.

Book a call
Scroll to Top