{"skills":[{"name":"Audit a spreadsheet formula block","description":"Find inconsistent formulas, replaced calculations and missing ranges using the worksheet\u2019s stated rules and neighbouring cells.","content":"# Audit a spreadsheet formula block\n\nFind inconsistent formulas, replaced calculations and missing ranges using the worksheet\u2019s stated rules and neighbouring cells.\n\n## When to use this skill\n\n- Someone has a spreadsheet or model and wants the formulas checked before using the numbers.\n- A total looks wrong, a row was inserted, or one cell in a column seems to have been typed over.\n- Excel's error-checking warnings flag inconsistent formulas and someone wants to know which matter.\n\n## When not to use it\n\n- Checking whether the model's assumptions or input data are right. The skill checks that formulas implement the stated calculation.\n- Comparing two versions of a workbook. Use the spreadsheet versions skill.\n- Checking a lookup formula's match mode or duplicate keys. Use the lookup table skill.\n\n## What you need\n\n- Formula view with cell addresses, source ranges and the intended calculation.\n- Any rows designated as overrides, rounding adjustments or subtotals.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What should each block calculate, in words? Without the intended rule a formula can only be compared with its neighbours.\n- Can you share the formulas with their cell addresses, not just the values? A values-only export cannot show a broken formula.\n- Are any rows deliberate overrides, manual adjustments or subtotals, and should each total include hidden or filtered rows?\n\n## Method\n\n1. Work from the formula view or a copy, and keep the workbook unchanged during review.\n2. Identify the role of each region from its headings and the stated calculation. Separate inputs, derived rows, overrides and summary cells before comparing neighbours.\n3. Translate each repeated formula to offsets from its own cell, as R1C1 notation does, so a shifted reference stands out. Keep absolute and mixed references as written. Check the translated operands against the calculation the block is meant to implement.\n4. Flag a literal value inside a derived range unless it is a documented override. Treat Excel's error-checking flags, such as a formula inconsistent with nearby formulas or one that omits adjacent cells, as leads to test against the stated rule, not as findings.\n5. Check each total for omitted data rows and for subtotals counted twice. Establish whether it should cover all rows or only visible ones. SUBTOTAL always ignores rows hidden by a filter; function numbers 1 to 11 include manually hidden rows and 101 to 111 exclude them; nested SUBTOTAL results inside its range are ignored.\n6. Propose the smallest justified correction with its cell address. Where the intent is unclear, ask before proposing an edit.\n7. Recalculate the corrected block on a copy and compare each total with an independent sum of the lines it should cover.\n\n## Checks before you deliver\n\n- An equal cached result can hide a broken formula. Formula text or a reproducible calculation is required.\n- Totals and override rows deliberately differ from adjacent rows. Establish their roles first.\n- Using SUBTOTAL(9, ...) when manually hidden rows should be excluded. Function 9 includes them; 109 leaves them out. Both ignore rows hidden by a filter.\n- Replacing a total with SUM over a range that contains subtotal rows counts those rows twice.\n- Correcting an absolute reference such as $B$1 that is meant to point at one fixed input.\n\n## How to present the result\n\nLead with the number of findings, or a clear statement that no discrepancy was established. Then give a table in row then column order: cell, what is wrong, current formula and proposed formula. Finish with any intent questions that block a fix, and the check to run after editing, such as comparing the total with an independent sum of its lines.\n\n## Worked example\n\n**Request:** Audit C2:C5. C2:C4 should equal that row's quantity in A times price in B. C5 totals those three results.\n\n**Supplied material:**\n\n```text\nC2 =A2*B2\nC3 24\nC4 =A4*B3\nC5 =SUM(C2:C3)\n```\n\n**Answer:** Restore C3 to =A3*B3 and change C4 to =A4*B4. Extend C5 to =SUM(C2:C4) so the subtotal includes all three order lines. Recalculate on a copy and compare the subtotal with the sum of those lines.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn findings in row then column order as objects with cell, issue and proposed. Use issue values literal, reference or total-range. proposed is the corrected Excel formula including its equals sign. Use an empty findings list when no discrepancy is established.\n\n## Sources\n\n- [Microsoft Excel: detect formula errors](https:\/\/support.microsoft.com\/en-us\/excel\/detect-formula-errors-in-excel): Excel's error-checking rules flag a formula that does not match the pattern of nearby formulas and one that omits adjacent cells, among others. The skill uses these as leads and decides each against the worksheet's stated rule.\n- [Microsoft Excel: SUBTOTAL function](https:\/\/support.microsoft.com\/en-us\/excel\/functions\/subtotal-function): Microsoft documents that function numbers 1 to 11 include manually hidden rows while 101 to 111 exclude them, that filtered-out rows are always excluded, and that nested subtotals are ignored to avoid double counting. The behaviour was also reproduced in LibreOffice Calc, where SUBTOTAL(9) and SUBTOTAL(109) gave different totals over a manually hidden row.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/audit-spreadsheet-formulas\n","scope":"contextual","trigger_keywords":["Audit a spreadsheet formula block","audit-spreadsheet-formulas","audit spreadsheet formulas","Can you check the formulas in this spreadsheet before I trust the totals?","Can you check the formulas in this spreadsheet before I trust the totals","audit these formulas","inconsistent spreadsheet formulas","formula outliers"],"is_private":true,"is_active":true,"scripts":[{"name":"audit-spreadsheet-formulas-check","description":"Compare a saved JSON answer with a published test. Pass tests\/case-1\/expected.json (or another case) and the path to your answer.","language":"python","filename":"audit-spreadsheet-formulas-check.py","content":"from pathlib import Path\nimport runpy\n\nrunpy.run_path(str(Path(__file__).parent \/ 'tests' \/ 'check.py'), run_name='__main__')\n","supporting_files":[{"path":"SKILL.md","content":"---\nname: audit-spreadsheet-formulas\ndescription: \"Audit a block of spreadsheet formulas for hard-coded values, shifted references and totals that miss rows or count subtotals twice, and propose the smallest fix. Use when someone asks to check Excel formulas, find formula errors or review a spreadsheet model before relying on its numbers.\"\nlicense: CC-BY-4.0\nmetadata:\n  author: Raq.com\n  version: \"2026-11-22\"\n  homepage: https:\/\/skills.raq.com\/skills\/audit-spreadsheet-formulas\n---\n\n# Audit a spreadsheet formula block\n\nFind inconsistent formulas, replaced calculations and missing ranges using the worksheet\u2019s stated rules and neighbouring cells.\n\n## When to use this skill\n\n- Someone has a spreadsheet or model and wants the formulas checked before using the numbers.\n- A total looks wrong, a row was inserted, or one cell in a column seems to have been typed over.\n- Excel's error-checking warnings flag inconsistent formulas and someone wants to know which matter.\n\n## When not to use it\n\n- Checking whether the model's assumptions or input data are right. The skill checks that formulas implement the stated calculation.\n- Comparing two versions of a workbook. Use the spreadsheet versions skill.\n- Checking a lookup formula's match mode or duplicate keys. Use the lookup table skill.\n\n## What you need\n\n- Formula view with cell addresses, source ranges and the intended calculation.\n- Any rows designated as overrides, rounding adjustments or subtotals.\n\n## Ask before you start\n\nIf any of these are missing or unclear, ask before doing the work.\n\n- What should each block calculate, in words? Without the intended rule a formula can only be compared with its neighbours.\n- Can you share the formulas with their cell addresses, not just the values? A values-only export cannot show a broken formula.\n- Are any rows deliberate overrides, manual adjustments or subtotals, and should each total include hidden or filtered rows?\n\n## Method\n\n1. Work from the formula view or a copy, and keep the workbook unchanged during review.\n2. Identify the role of each region from its headings and the stated calculation. Separate inputs, derived rows, overrides and summary cells before comparing neighbours.\n3. Translate each repeated formula to offsets from its own cell, as R1C1 notation does, so a shifted reference stands out. Keep absolute and mixed references as written. Check the translated operands against the calculation the block is meant to implement.\n4. Flag a literal value inside a derived range unless it is a documented override. Treat Excel's error-checking flags, such as a formula inconsistent with nearby formulas or one that omits adjacent cells, as leads to test against the stated rule, not as findings.\n5. Check each total for omitted data rows and for subtotals counted twice. Establish whether it should cover all rows or only visible ones. SUBTOTAL always ignores rows hidden by a filter; function numbers 1 to 11 include manually hidden rows and 101 to 111 exclude them; nested SUBTOTAL results inside its range are ignored.\n6. Propose the smallest justified correction with its cell address. Where the intent is unclear, ask before proposing an edit.\n7. Recalculate the corrected block on a copy and compare each total with an independent sum of the lines it should cover.\n\n## Checks before you deliver\n\n- An equal cached result can hide a broken formula. Formula text or a reproducible calculation is required.\n- Totals and override rows deliberately differ from adjacent rows. Establish their roles first.\n- Using SUBTOTAL(9, ...) when manually hidden rows should be excluded. Function 9 includes them; 109 leaves them out. Both ignore rows hidden by a filter.\n- Replacing a total with SUM over a range that contains subtotal rows counts those rows twice.\n- Correcting an absolute reference such as $B$1 that is meant to point at one fixed input.\n\n## How to present the result\n\nLead with the number of findings, or a clear statement that no discrepancy was established. Then give a table in row then column order: cell, what is wrong, current formula and proposed formula. Finish with any intent questions that block a fix, and the check to run after editing, such as comparing the total with an independent sum of its lines.\n\n## Worked example\n\n**Request:** Audit C2:C5. C2:C4 should equal that row's quantity in A times price in B. C5 totals those three results.\n\n**Supplied material:**\n\n```text\nC2 =A2*B2\nC3 24\nC4 =A4*B3\nC5 =SUM(C2:C3)\n```\n\n**Answer:** Restore C3 to =A3*B3 and change C4 to =A4*B4. Extend C5 to =SUM(C2:C4) so the subtotal includes all three order lines. Recalculate on a copy and compare the subtotal with the sum of those lines.\n\n## Structured output for tests\n\nFor an ordinary job, answer in the format above and point back to the supplied evidence. Use this structure only for the test cases published with this skill, or when someone asks for structured JSON.\n\nReturn findings in row then column order as objects with cell, issue and proposed. Use issue values literal, reference or total-range. proposed is the corrected Excel formula including its equals sign. Use an empty findings list when no discrepancy is established.\n\n## Sources\n\n- [Microsoft Excel: detect formula errors](https:\/\/support.microsoft.com\/en-us\/excel\/detect-formula-errors-in-excel): Excel's error-checking rules flag a formula that does not match the pattern of nearby formulas and one that omits adjacent cells, among others. The skill uses these as leads and decides each against the worksheet's stated rule.\n- [Microsoft Excel: SUBTOTAL function](https:\/\/support.microsoft.com\/en-us\/excel\/functions\/subtotal-function): Microsoft documents that function numbers 1 to 11 include manually hidden rows while 101 to 111 exclude them, that filtered-out rows are always excluded, and that nested subtotals are ignored to avoid double counting. The behaviour was also reproduced in LibreOffice Calc, where SUBTOTAL(9) and SUBTOTAL(109) gave different totals over a manually hidden row.\n\nTest cases and an answer checker for this skill: https:\/\/skills.raq.com\/skills\/audit-spreadsheet-formulas\n"},{"path":"LICENSE.txt","content":"Original Raq.com instructions and synthetic examples: CC BY 4.0.\nhttps:\/\/creativecommons.org\/licenses\/by\/4.0\/\nAttribution: Raq.com, https:\/\/skills.raq.com\/skills\/audit-spreadsheet-formulas\nReferenced third-party materials retain their own terms.\n"},{"path":"examples\/worked-example.md","content":"# Order extension and subtotal\n\nAudit C2:C5. C2:C4 should equal that row's quantity in A times price in B. C5 totals those three results.\n\n## Supplied material\n\nC2 =A2*B2\nC3 24\nC4 =A4*B3\nC5 =SUM(C2:C3)\n\n## Worked answer\n\nRestore C3 to =A3*B3 and change C4 to =A4*B4. Extend C5 to =SUM(C2:C4) so the subtotal includes all three order lines. Recalculate on a copy and compare the subtotal with the sum of those lines.\n\n## Reasoning\n\nOne cell is a literal, one references the preceding price and the total ends a row early.\n"},{"path":"tests\/check.py","content":"\"\"\"Check a saved agent answer locally with Python 3 (standard library only).\"\"\"\nimport json\nimport math\nimport sys\nfrom pathlib import Path\n\n\ndef compare(expected, actual, path=\"$\", accepted=None):\n    if isinstance(expected, bool) or isinstance(actual, bool):\n        if expected is not actual:\n            yield path\n    elif isinstance(expected, (int, float)) and isinstance(actual, (int, float)):\n        if not math.isclose(expected, actual, rel_tol=0, abs_tol=1e-8):\n            yield path\n    elif isinstance(expected, dict) and isinstance(actual, dict):\n        for key in sorted(set(expected) | set(actual)):\n            if key not in expected or key not in actual:\n                yield f\"{path}.{key}\"\n            elif not any(\n                not list(compare(option, actual[key]))\n                for option in (accepted or {}).get(key, [])\n            ):\n                yield from compare(expected[key], actual[key], f\"{path}.{key}\")\n    elif isinstance(expected, list) and isinstance(actual, list):\n        if len(expected) != len(actual):\n            yield f\"{path} (length)\"\n        for i, (left, right) in enumerate(zip(expected, actual)):\n            yield from compare(left, right, f\"{path}[{i}]\")\n    elif type(expected) != type(actual) or expected != actual:\n        yield path\n\n\ndef main():\n    if len(sys.argv) != 3:\n        raise SystemExit(\"Usage: python3 check.py expected.json answer.json\")\n    try:\n        expected, actual = [json.loads(Path(p).read_text(encoding=\"utf-8\")) for p in sys.argv[1:]]\n        alternatives = Path(sys.argv[1]).with_name(\"accepted.json\")\n        accepted = json.loads(alternatives.read_text(encoding=\"utf-8\")) if alternatives.is_file() else {}\n    except (ValueError, OSError) as error:\n        raise SystemExit(str(error))\n    differences = list(compare(expected, actual, accepted=accepted))\n    if differences:\n        raise SystemExit(\"Different fields: \" + \", \".join(differences))\n    print(\"Pass\")\n\n\nif __name__ == \"__main__\":\n    main()\n"},{"path":"tests\/README.md","content":"Give your agent SKILL.md and one request.txt in a fresh session. Keep the expected answer aside. Save the reply as answer.json, then run this from the tests folder:\n\n    python3 check.py case-1\/expected.json answer.json\n\nEach case also has an explanation. Where accepted.json exists, the checker accepts the alternatives listed there.\n"},{"path":"tests\/case-1\/request.txt","content":"Audit C2:C5. C2:C4 should equal that row's quantity in A times price in B. C5 totals those three results.\nReturn only the JSON specified in SKILL.md for this test.\n\nC2 =A2*B2\nC3 24\nC4 =A4*B3\nC5 =SUM(C2:C3)\n"},{"path":"tests\/case-1\/expected.json","content":"{\n    \"findings\": [\n        {\n            \"cell\": \"C3\",\n            \"issue\": \"literal\",\n            \"proposed\": \"=A3*B3\"\n        },\n        {\n            \"cell\": \"C4\",\n            \"issue\": \"reference\",\n            \"proposed\": \"=A4*B4\"\n        },\n        {\n            \"cell\": \"C5\",\n            \"issue\": \"total-range\",\n            \"proposed\": \"=SUM(C2:C4)\"\n        }\n    ]\n}\n"},{"path":"tests\/case-1\/explanation.txt","content":"One cell is a literal, one references the preceding price and the total ends a row early.\n"},{"path":"tests\/case-2\/request.txt","content":"Audit column C. Use A times the fixed input B1. Row 3 is a documented manual credit. C5 totals C2:C4.\nReturn only the JSON specified in SKILL.md for this test.\n\nC2 =A2*$B$1\nC3 -5\nC4 =A4*$B$1\nC5 =SUM(C2:C4)\n"},{"path":"tests\/case-2\/expected.json","content":"{\n    \"findings\": []\n}\n"},{"path":"tests\/case-2\/explanation.txt","content":"The absolute reference and manual adjustment are both intentional.\n"},{"path":"tests\/case-3\/request.txt","content":"Audit D9 as the grand total and D10 as the sum of visible rows only. Require the visible total to exclude manually hidden rows too.\nReturn only the JSON specified in SKILL.md for this test.\n\nD2:D8 are valid line balances. The six visible amounts sum to 52. A filtered-out line contains 10. D9 =SUM(D2:D8). D10 =SUM(D2:D8).\n"},{"path":"tests\/case-3\/expected.json","content":"{\n    \"findings\": [\n        {\n            \"cell\": \"D10\",\n            \"issue\": \"total-range\",\n            \"proposed\": \"=SUBTOTAL(109,D2:D8)\"\n        }\n    ]\n}\n"},{"path":"tests\/case-3\/explanation.txt","content":"The grand total correctly includes all 62. SUBTOTAL with function 109 sums visible lines and also excludes manually hidden rows.\n"}],"is_active":true,"is_approved":false}]}]}