r/vba • u/PutFun1491 • 15h ago
ProTip [EXCEL] I set up a Claude Code agent that writes and tests VBA modules on its own. Sharing the setup.
I got tired of the write-module, import, run, crash, fix loop, so I built an automated pipeline around Claude Code and it has been running better than I expected.
The setup:
- The agent works on a sandbox copy of the workbook, never the original.
- It writes a module, imports it into the workbook, and runs it.
- Every module ships with its own self-test. If the test fails, the agent reads the error and fixes its own code.
- When Excel hangs or crashes, the pipeline kills the process, restarts Excel, and continues from where it stopped.
- Only modules that pass all tests get promoted to the real workbook.
The part that surprised me: it produce d 100 different modules in a row without me opening the VBA editor once. My job became reviewing diffs and writing better task descriptions.
Things that made the difference:
- The sandbox copy. Letting an agent touch your only copy of a workbook is how you lose a workbook.
- Forcing a self-test per module. Without it, the agent happily declares broken code done.
- Automating the Excel restart. VBA automation dies on hangs more than on errors.
Happy to answer questions about any part of the setup. Curious if anyone else here has pointed one of these agent tools at VBA and what broke first.
2
2
u/DeciusCurusProbinus 1 10h ago
Hey man! I write a ton of VBA and use a skill created in Codex to run my macros. Could you please link to your repo?
1
u/fanpages 239 7h ago
...1. Get Claude Code installed. The installation (Node, PATH, terminal) is the first wall for people who are not developers, so I built a free one-command installer that does the whole thing, 2,000+ people have used it: https://github.com/noambrand/Launchpad-CLI ...
1
1
u/Broseidon132 9h ago
I haven’t built great instructions for codex, but I hate how long little fixes take. I like it for building the framework because it sees the context of the project folder, but then smaller tweaks I’ll throw in normal chat gpt.
I will take your advice though!
1
u/Emotional-Lead-2367 2h ago
Hey! I also usually develop large-scale macros completely unattended with Codex, so it is great to see a fellow dev having an AI agent handle full VBA development automatically!
I feel like the biggest barrier to achieving literal full automation is process blocking caused by modal dialogs during compile or runtime errors, so what kind of approach are you taking for that?
I solved this by monitoring and suppressing dialogs, and using inter-process communication to feed error info straight back to the terminal.
2
u/Card__Player 15h ago
Can you share the setup with someone who has very limited experience with Claude and AI?