
Replacing a 240KB Excel Macro With a Local Full-Stack MES
Our BOM macro grew to 240KB of VBA and cracked as the SMT line scaled, so I replaced it with a local Python, SQLite and Eel application.
- Published
- February 9, 2026
- Author
- Hrushiekesh Reddy Kanjula
- Read time
- ~5 min
- Category
- engineering

We had a 240KB Excel macro that nobody understood and nobody wanted to touch. It summarized Bills of Materials (BOMs), cross-referenced component libraries, flagged substitutions and generated production reports. It worked, but only just. Once the SMT line scaled, with more boards, more component variants and tighter tolerances, it started to crack.
I replaced it. The migration was harder than I expected.
Why the macro failed
The 240KB size is a symptom. A healthy macro is tight and purpose-built, maybe 10-20KB. At 240KB it carries years of patches: functions calling functions, global variables nobody dares rename, and no version control. Git doesn't track .xlsm files the way it tracks .py files, so every change was a leap of faith.
The bigger problem is where VBA runs. A macro lives inside Excel. It is exposed to everything on that machine at that moment: screen resolution quirks, the installed Office version, shared network drives timing out. In a factory those are not edge cases. They are Monday morning.
The SMT context makes it worse. A BOM tool has to query live APIs, connect to machine interfaces and handle hundreds of thousands of component records. VBA has no meaningful concurrency model. Every API call blocks, and every processed row is another tick of a frozen UI. That is fine for 10 rows. For 50,000 components it doesn't work.
What the replacement needed
Writing the same thing in Python was not enough. The production environment now asked for four things.
External API connectivity. The component library had to sync against the Mouser Electronics REST API for real-time pricing, availability and parametric data. That is simple with Python's requests or httpx. In VBA, HTTP calls are COM object rituals.
A direct machine interface. The SMT placement machines expose data through CGI endpoints, a thin HTTP layer over machine telemetry. Reading live machine state, error logs and production counters needed a proper HTTP client with retry logic, timeouts and structured error handling. VBA could do it in theory. Python does it in 15 lines.
Local data persistence. The data layer is a local SQLite database on the edge machine, not a cloud database or a shared network drive. It stores millions of component records and queries them in under 50ms. Factory network connectivity is unreliable by design, so the system has to work offline.
A real UI. Production engineers are not developers. The interface had to be fast, clear and fit their workflow. It couldn't be a grey Excel dialog.

Three phases
The migration took three phases. The first two were painful.
Phase one, direct translation. I converted the VBA to Python line by line. It felt productive and was almost entirely wrong. VBA macros are written for the Excel object model, not for general computation. What looked like a BOM parser was about 60% worksheet manipulation dressed up as logic. Once I stripped out the Excel scaffolding, very little domain logic was left. We ended up writing it from scratch.
Phase two, the API integration. The Mouser API is well documented. The real-world component data is not. A single 10kΩ resistor can show up in eight formats across BOM files: "10k Res", "Resistor 10 kilohm", "RES 10K 1%", "10000 Ohm SMD". Mouser returns clean canonical data. Customers send anything but. The normalization layer between the two became one of the most complex parts of the system. I'll cover it in a future post.
Phase three, full-stack integration. This was a SQLite backend, Python business logic and a JavaScript/CSS frontend rendered through a local server. The Eel framework bridged Python and JavaScript. This is where the design settled. Every component had a clear responsibility, a testable surface and a commit history.
What "full-stack" means here
On the web, full-stack means frontend plus backend. On an edge manufacturing floor, I mean something narrower. It is a self-contained, locally deployed application. It bridges machines and operators, has its own data layer, business logic and UI, and works when the internet doesn't.
That changes the architecture. You don't reach for Django or FastAPI. You don't provision a cloud database. You pick tools that are light, portable and deterministic. Python, SQLite and a browser-mode Chrome window running local JavaScript fit that well.

The macro did have one real virtue. It worked on anyone's laptop with Excel installed. The replacement had to match that simplicity: a single executable, a local database file and no server to manage. That constraint shaped every later choice.
What I took from it
The macro didn't fail because Excel is bad or VBA is wrong for small scripts. The problem outgrew the tool, and the tool was never built to evolve. I'd choose technology that can grow with the problem, not the best one in the abstract.
The replacement isn't perfect. But it can be tested, versioned, debugged and extended. Someone who joined last month can understand it. In manufacturing that is the difference between a system you trust and one you pray at.

The assembly hub I'm building is the direct descendant of that decision. The BOM normalizer, the machine interface layer and the SQLite schema will each get their own post.