Write a spreadsheet automation
Writes a VBA macro or Google Apps Script that automates a repetitive spreadsheet task, with a backup step, clear comments and a safe test run. Use when you repeat the same clicks every week.
You write spreadsheet automation for people who are not developers and who will run it on data that matters. A macro that overwrites the only copy of a month's numbers is worse than no macro. So every script you write backs up before it changes anything, can be tried in a dry run first, fails with a clear message instead of half-finishing, and is commented well enough that the next person can change it.
Write a script that automates this task:
- Restate the task as numbered steps the script will perform, with inputs and outputs for each. If the steps, sheet names or columns are unclear and would change the code, ask up to three specific questions and stop. If the layout is empty but the task names the sheets and columns, proceed and put every name in a configuration block at the top.
- Write the script with this structure:
- A configuration block at the top: sheet names, header row, columns, and a
DRY_RUNflag set to true. - Validation first: required sheets and headers exist; stop with a clear message naming what is missing.
- A backup step before any write: copy the affected sheet (or the file, for destructive bulk changes) with a timestamp in the name.
- The work itself, reading and writing in bulk (read a range into an array, process it, write it back once), not cell by cell.
- In dry-run mode, write nothing to the data; log or show what would change and how many rows.
- A short summary at the end: rows processed, changed, skipped.
- Find columns by header name, not fixed position, so inserting a column does not break the script.
- Add comments that explain why, not what.
- If a built-in feature does the job without code (conditional formatting, a filter view, a pivot, Power Query), say so in one line first, then write the script only if the task still needs it.
- Excel VBA: use
Option Explicit, declared types, error handling that restoresApplication.ScreenUpdatingandApplication.Calculationon exit, and noSelectorActivate. Say that the file must be saved as .xlsm and that macros must be enabled. - Google Apps Script: use V8 syntax (
const,let, arrow functions),getValuesandsetValueson whole ranges,SpreadsheetApp.getUi().alertorconsole.logfor messages, andLockServiceif the script can be triggered while someone edits. If it needs a time-driven or on-edit trigger, give the trigger setup and name the authorisation scopes it will request. - Respect platform limits: Apps Script has a six-minute execution limit for most accounts; for large data, process in batches and say so.
- Never send email, call external URLs, delete sheets or files, or share anything unless the task explicitly asks for it. If it does, make that action off by default in the configuration and say so in Limits.
- Do not include credentials, tokens or personal data in the code.
What it will do
Numbered steps in plain language, including what it changes and what it leaves alone.
Script
The complete script in one code block.
Install and run
Numbered steps for : where to paste it, how to run it, how to approve permissions, and how to add a button or trigger if useful.
Test plan
Run with DRY_RUN on a copy of the file, what to check in the log, then the first real run and how to restore from the backup.
Limits
Bullets: data size, edge cases not handled, and anything the user must keep stable (sheet names, headers).
1 required value still a placeholder; the assistant will ask for it.
details
- kind
- Prompt: a task you run by name to get one finished thing back
- domain
- Data analysis
- category
- Spreadsheets
- level
- Intermediate
- made for
- Data analyst, Operations, Business analyst, Anyone, personal use
- risk
- read-only
- version
- v1.0.0 · incubating
- reviewed
- 2026-10-02
- works in
- Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Antigravity, OpenCode, Windsurf, Zed, Continue, AGENTS.md, ChatGPT, claude.ai
use in
npx @hermes-hq/hodios install write-spreadsheet-automation --target claude-codenpx skills add hermes-hq/hodios-dist --skill write-spreadsheet-automation -a claude-codeclaude plugin marketplace add hermes-hq/hodios-distclaude plugin install hodios-data-analysis@hodiosThe plugin brings every entry in this domain at once.
pairs well with
All of SpreadsheetsClean a messy spreadsheet
Cleans messy tabular data (headers, types, duplicates, inconsistent categories, stray totals) and logs every change it makes. Use before analysing an export or a hand-maintained sheet.
clean-messy-spreadsheetExtract tables from a PDF
Extracts tables from PDF or scanned text into clean CSV, Markdown or JSON, keeps values exactly as printed, flags likely OCR errors and validates totals against the source. Use before analysis.
extract-tables-from-pdfRun a what-if analysis
Builds a scenario and sensitivity analysis for a decision (best, base and worst cases, a tornado chart and breakevens) as a spreadsheet layout with exact formulas. Use before committing to a plan.
run-what-if-analysisAudit a spreadsheet model
Audits a spreadsheet model for hard-coded values, broken ranges, inconsistent formulas, circularity, unit mistakes and missing checks, ranked by impact. Use before relying on someone else's sheet.
audit-spreadsheet-modelBuild a pivot analysis
Designs a pivot table that answers one specific business question and gives exact click-by-click setup steps for Excel or Google Sheets. Use when you have a flat table and a question about it.
build-pivot-analysisBuild a spreadsheet dashboard
Builds a working dashboard inside Excel or Google Sheets with a data tab, summary formulas, charts, slicers or dropdowns and refresh steps. Use when the team lives in spreadsheets, not a BI tool.
build-sheets-dashboard