Turn a fragile manual workbook into a three-layer system with a readme.
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.
Read the workbook and record:
01_Input, 02_Calc, 03_Report).=A2*0.18 - the 18% should be a named cell).NOW(), INDIRECT(), OFFSET() used at scale).| Layer | Sheet | Rule |
|---|---|---|
| Input | 01_Input | Only raw data. No formulas. Formatted as a real Excel Table / named range. |
| Calculation | 02_Calc | All logic. Formulas only. Never hand-edited. |
| Output | 03_Report | Pivots, charts, dashboard. No raw data. |
Never mix layers. This single rule eliminates most spreadsheet bugs.
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 "".
=COUNTIF(tblSales[Invoice No],[@[Invoice No]])>1.04_Readme sheet: what the file does, where to paste data, what each output means, who to call.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.
Under 20k rows formulas are fine. Above that:
VLOOKUP with XLOOKUP on a Table column.SpreadsheetApp.flush() after).INDIRECT, OFFSET, ARRAYFORMULA over whole columns, and thousands of IFERROR wrappers.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.
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.