← All skills
Automation https://ai-skills-vault.pages.dev/skills/spreadsheet-automation-agent.md

Spreadsheet Automation Agent

Turn a fragile manual workbook into a three-layer system with a readme.

Download .md All skills
Install URLhttps://ai-skills-vault.pages.dev/skills/spreadsheet-automation-agent.md
Install prompt tap to copy
Read the skill at https://ai-skills-vault.pages.dev/skills/spreadsheet-automation-agent.md and install it as a skill in your agent. Follow it exactly, including its checklists. Then ask me the questions it requires and do the work.

Most business spreadsheets are one person's memory written in cells. This skill converts that into a system that survives their holiday.

When to use this skill

Stage 1 - Structure audit

Read the workbook and record:

  1. Sheets and their job - input, calculation, output, reference, archive. Name them so (01_Input, 02_Calc, 03_Report).
  2. Row grain - what is one row?
  3. Merged cells, blank rows/columns inside data, subtotal rows, two tables on one sheet. All four break formulas and pivots. Remove them.
  4. Hard-coded values inside formulas (=A2*0.18 - the 18% should be a named cell).
  5. Circular references and volatile functions (NOW(), INDIRECT(), OFFSET() used at scale).
  6. Colour coding - is it meaningful (input vs calculated) or decorative?
  7. Who else opens this file, and do they need to edit?

Stage 2 - The three-layer architecture

LayerSheetRule
Input01_InputOnly raw data. No formulas. Formatted as a real Excel Table / named range.
Calculation02_CalcAll logic. Formulas only. Never hand-edited.
Output03_ReportPivots, charts, dashboard. No raw data.

Never mix layers. This single rule eliminates most spreadsheet bugs.

Stage 3 - Formula library

Use dynamic arrays and structured references so formulas survive row growth.

Total row count        =ROWS(tblSales[ID])
Lookup (any column)    =XLOOKUP([@SKU], tblProducts[SKU], tblProducts[Price], "not found")
Conditional sum        =SUMIFS(tblSales[Amount], tblSales[Region], [@Region], tblSales[Date], ">="&start)
Distinct count         =COUNTA(UNIQUE(tblSales[Customer]))
Running total          =SUMIFS(tblSales[Amount], tblSales[Date], "<="&[@Date])
Rank within group      =COUNTIFS(tblSales[Region],[@Region],tblSales[Amount],">"&[@Amount])+1
Month bucket           =EOMONTH([@Date],0)
Text clean             =TRIM(CLEAN([@Raw]))

Rules: XLOOKUP over VLOOKUP; SUMIFS over SUMPRODUCT unless genuinely needed; no whole-column references (A:A) inside big tables; every constant lives in a named cell on a 00_Config sheet; wrap fragile parses in IFERROR with a visible sentinel like "CHECK" rather than "".

Stage 4 - Data integrity

Stage 5 - Reporting layer

Stage 6 - Automation

Google Sheets (Apps Script) - onEdit for validation and stamping, time-driven triggers for nightly rollups, UrlFetchApp for API pulls.

function onEdit(e) {
  const sh = e.range.getSheet();
  if (sh.getName() !== "01_Input" || e.range.getColumn() !== 1) return;
  sh.getRange(e.range.getRow(), 8).setValue(new Date()); // stamp
}

Excel - Office Scripts (cloud, preferred) or VBA (desktop only). Prefer Power Query for all ingestion and transformation: it is refreshable, auditable and no code.

Power Query: Folder -> combine CSVs -> clean types -> load to Table

Rules: every automation is idempotent (running twice changes nothing), logs to a 99_Log sheet (timestamp, rows affected, outcome), and never deletes data - archive instead.

Stage 7 - Performance

Under 20k rows formulas are fine. Above that:

Stage 8 - Handover

Deliver a one-page README covering: purpose, sheet map, where to paste data, how to refresh, what the exception colours mean, known limitations, and the change log. Test it by having someone else run the monthly process from the README alone. If they cannot, the file is not done.

Quality checklist

Copy-ready agent prompt

Read the skill at the URL above. I will attach my workbook (or describe it). First run the Stage 1 audit and list every structural problem with the sheet and cell range. Then propose the three-layer rebuild, write the formula library with named ranges, add validation and conditional formatting, automate the repetitive step, and produce the Readme. Give me exact formulas and script code I can paste - no pseudocode.
Copied