Blog · 24 October 2026 · 7 min read

How to Build an Agent for Excel: A Worked Example

Building an agent for Excel means handing it a multi-step task, not one formula. A worked reconciliation example, where it breaks, and the checks first.

Name the task. Give it steps. Check the result.

An "agent" for Excel is not a fancier formula and not a macro with a better name. A formula or a macro does exactly what you specified, every time, inside one workbook. An agent is given a goal and a set of tools — read this sheet, write to that cell, call this other app — and it decides the steps itself, which is what makes it useful for a task that has more than one move in it and genuinely risky the moment it has write access to something that matters. Excel automation covers the macro-versus-script-versus-just-ask decision; this is the step beyond all three, where the tool is choosing the sequence rather than following one you wrote.

What makes it an agent, not a formula

  • It plans a sequence of steps toward a goal rather than executing one fixed set of instructions — AI agent vs LLM: what’s actually different covers this distinction in full, and it is the one that matters here.
  • It calls tools — reading a range, writing a range, opening another file, sending a message — rather than only generating text.
  • It can fail partway through a multi-step task and either keep going on a wrong assumption or stop and ask, depending on how it was built. A macro cannot do either; it just runs the line it was given.

A worked example: reconciling a shared expense sheet

Inputs: a shared workbook where three people log expenses into one tab, inconsistently — some rows have a category, some do not, and a handful of entries get pasted in twice when someone double-submits a form. The goal: a clean monthly summary by category, with duplicates flagged rather than silently dropped.

Weak instruction: "Clean up this expense sheet and summarise it." That hands the agent three different jobs — deciding what counts as a duplicate, deciding what counts as a category, and deciding how to summarise — with no way to tell afterward which decision it made where.

Better instruction, given as a sequence: "First, list every row where the amount, date and payee all match another row — do not delete anything, just flag candidate duplicates in a new column with the row number of the match. Second, for any row missing a category, leave it blank and count it separately rather than guessing one. Third, once I confirm the flagged duplicates, build a summary tab totalling the remaining rows by category, with the uncategorised total shown on its own line." Each step produces something checkable before the next one runs, which is the actual point — not three sentences into one request, three separate, inspectable results.

The usable result is the flagged-duplicates list and the categorised summary — not a final "all done" message. A worked reconciliation agent like this is close to what Microsoft positions Copilot Cowork for inside Microsoft 365 — building a workbook from a goal, with the user seeing proposed actions before they are applied, rather than typing one formula at a time. OpenAI’s equivalent, dots, takes the same shape from a different vendor: a goal, a set of file and app tools, and a review step before anything it does is kept.

Where it breaks

  • Fuzzy duplicates. Two rows for the same taxi ride, one logged as "$42.00 Uber" and the other as "$42 Uber — airport", are the same expense to a person and easy for an agent to miss or to wrongly match against something unrelated entirely.
  • A confident, wrong category. Asked to categorise an ambiguous row, a model will usually pick something plausible and move on rather than leaving it blank — the behaviour is the same fluent-but-not-necessarily-correct output documented across large language models generally, and a spreadsheet gives it nowhere to visibly hedge the way a sentence can.
  • Scope creep mid-task. Given write access to fix the duplicates it flagged, an agent can go further than asked — reformatting cells, reordering columns, "improving" the summary layout — because nothing told it where the task actually ends.

Checks before you trust the output

  1. Give it read access first and write access only once the plan looks right — OWASP’s guidance on excessive agency names this directly: the control that actually works is a human approval step before a high-impact action runs, not a system prompt asking it to be careful.
  2. Ask for flagged candidates, never silent deletions or silent edits, on the first pass of any task that touches shared data.
  3. Spot-check the uncategorised and flagged-duplicate rows by hand before trusting the summary total — these are exactly the rows most likely to have been decided quietly.
  4. Re-run the same task a second time on the same data and compare the two summaries. A deterministic formula gives you the same answer twice; an agent’s plan can legitimately differ, and a second run is the cheapest way to notice that before anyone downstream sees the number.

What to do Monday

Pick one Excel task that currently takes you several manual steps — not one formula, several — and write it as a numbered sequence with a checkable result after each step, the way the reconciliation example above is written, before handing any of it write access. Agentic framework: do you actually need one? is worth reading first if you are deciding whether to build this yourself or reach for an existing tool, and AI agent marketplace: what to check before you install one covers the install-instead-of-build path if a general-purpose listing already does something close to what you need. Code for Excel is the right next read if the steps turn out to be better handled as a script than as an ongoing agent once you have seen what the task actually involves.

Knowing which step of a task to hand over and which to keep checking by hand is the same judgement behind the wage premium PwC has been tracking for workers with measurable AI skills — 62%, up from 57% the year before. Coursium teaches that judgement directly, one short lesson at a time. Stay ahead of AI by learning the tools on your phone.

Coursium

Stay ahead of AI — learn the tools on your phone.

Get the app