Excel Formula and Error Audit
Operator: Abdulla Al Fahad. How tools are built and checked
Spreadsheet models rarely fail loudly. A formula copied down a column picks up the wrong row in one cell, a tax rate gets typed straight into a total, a lookup starts returning #N/A after a supplier code changes, and a summary sheet keeps reading figures from a workbook on a colleague's laptop. Each of these leaves the file looking finished. The numbers are simply wrong, or quietly out of date.
This audit opens an .xlsx and goes through every formula on every sheet looking for five things: cells whose saved value is an error, numbers typed into formulas, a formula that breaks the pattern of the copies around it, references to other workbooks, and functions that recalculate on every change. The findings are listed by cell with the formula next to them, can be filtered by type, and download as an XLSX report with one sheet per type or as a single CSV.
Key features
- Every cell holding #REF!, #N/A, #DIV/0!, #VALUE!, #NAME?, #NUM!, #NULL!, #SPILL!, #CALC! or #GETTING_DATA, with its formula and a plain-language reason
- Numbers typed into formulas listed per cell, ignoring 0 and 1, digits inside cell references, sheet names and quoted text
- Odd-one-out detection in runs of three or more formulas, using each formula's relative pattern so =B2*2 and =B3*2 count as the same formula
- Totals and subtotals at the end of a block, and the opening row of a running balance, left out of the inconsistency list
- External references resolved from [1]-style indexes to the file path stored in xl/externalLinks, plus defined names that point at other workbooks
- NOW, TODAY, RAND, RANDBETWEEN, RANDARRAY, OFFSET, INDIRECT, INFO and CELL flagged, including when they are hidden inside a defined name
- Filter chips by finding type, and reports in XLSX or CSV
How formulas are read and reported
Input is one .xlsx workbook of up to 25 MB. Older .xls files and workbooks protected with a password to open are not ZIP archives, so they are refused with a message saying so; Excel binary workbooks (.xlsb) are refused too. A workbook whose parts would unpack to more than 400 MB of XML is treated as damaged and not read. Macro-enabled .xlsm files are read like ordinary workbooks, because the audit only reads and never writes the file back.
Formulas are read with SheetJS, including shared formulas, where Excel stores the formula once and marks the rest of the filled range as copies; each copy is expanded to its own text before it is checked. The value shown next to each formula is the one Excel cached at the last save. Nothing is recalculated, so the audit sees exactly what the file says, which is also what anyone you send it to will see before their own copy recalculates.
The XLSX report has a Summary sheet with formula and finding counts per sheet, followed by sheets named Errors, Hard-coded numbers, Inconsistent formulas, External references and Volatile functions. Each row gives the sheet, cell, formula, saved value, what was found and a one-line explanation, and formula text is stored as plain text so the report never runs it. The CSV holds the same rows plus a Type column; the file opens with a UTF-8 byte-order mark, and every line ends in CRLF. Each formula is written with an apostrophe before its equals sign, as in '=A4*B3, and any other field that begins with =, +, - or @ and is not a plain number gets the same apostrophe; delete it if you paste a formula from the CSV back into a workbook.
How it works
Each formula is split into tokens by a small lexer that knows the pieces of Excel's formula language: quoted strings, numbers and percentages, cell and range references with or without $ signs, whole rows and columns, sheet prefixes in quotes or without, external prefixes such as [1] or 'C:\Data\[Rates.xlsx]Rates'!, table references in square brackets, function names, defined names and error literals. LOG10( and DEC2BIN( look like cell addresses but are followed by a bracket, so they are read as functions; a name such as XFE1 lies beyond the last column, so it is read as a name.
For the inconsistency check, every reference is rewritten relative to its own cell, the way Excel's R1C1 notation does it. =B3*2 in A3 becomes RC[1]*2, and so does =B4*2 in A4, so copies of one formula compare equal while =B3*3 does not. The audit then walks each column and each row looking for unbroken runs of three or more formula cells. When more than half of a run shares one pattern, each cell that differs is reported, with the nearest matching cell given as an example of what the formula was expected to look like.
Two kinds of cell that differ on purpose are left out. A cell whose range reaches the cell next to it in the run is treated as a total or subtotal, so =SUM(D2:D5) under D2:D5 is not reported, while =SUM(D2:D4) in the same place, which stops one row short, is. And a first or last cell that its neighbour builds on is treated as an opening value: in a running balance where E3 is =E2+D3, the different formula in E2 is expected.
Hard-coded numbers are the number tokens left after strings and references are set aside, other than 0 and 1. A minus sign is an operator, so -1 counts as 1 and is skipped, while 5% is listed as 5%. Volatile functions and external prefixes are found among the same tokens, and defined names are checked once so that a formula using a name built on OFFSET, or a name pointing at [2]Inputs!$B$4, is reported along with the name it goes through.
When to run it
- Reviewing a financial model a colleague built before its numbers go into a board pack
- Checking a pricing workbook received from a supplier or client before relying on its totals
- Finding which cells still read from last year's budget file before archiving the folder it lives in
- Tracking down why a workbook recalculates slowly, by listing OFFSET, INDIRECT and other volatile functions
- Handing over a reporting workbook with a written list of the known #N/A cells and why they are there
Running a check
- Pick the workbook, or press Try a sample workbook to load a small sales sheet that contains one of each common problem.
- Read the summary table first: it shows how many formulas each sheet holds and how many findings of each type it produced.
- Use the filter chips to look at one type at a time. Inconsistent formulas and error values usually deserve attention before the rest.
- For each inconsistent formula, compare it with the example cell named in the finding and decide which one is right.
- Download the XLSX report to work through the list with a colleague, or the CSV to load the findings into another tool.
- Fix the workbook in Excel, save it, and run the audit again to confirm the list has shrunk.
Example
sales.xlsx, sheet Sales (units in A, price in B)
C2 =A2*B2 540
C3 =A3*B3 480
C4 =A4*B3 1,200 (should use B4: 200 x 3 = 600)
C5 =A5*B5 540
C6 =SUM(C2:C5) 2,760
C8 =SUM(C2:C5)*1.2 3,312
C9 =C6/E9 #DIV/0! (E9 is empty)
C10 =NOW() 2026-11-11 12:00Audit findings
Inconsistent formulas Sales!C4 =A4*B3
Column block C2:C6: 3 of its 5 formulas share one pattern, as in C3 (=A3*B3)
Hard-coded numbers Sales!C8 1.2
Error values Sales!C9 #DIV/0! Division by zero, or by a cell that is empty
Volatile functions Sales!C10 NOW
C6 is not listed: its range C2:C5 reaches the cell above it, so it is read as the total.
With C4 corrected to =A4*B4, the total falls from 2,760 to 2,160.Tips for best results
- A rounding argument such as ROUND(A2,2) and a VLOOKUP column number count as hard-coded numbers. Filter to that type and skim; the ones worth moving into an input cell are rates, thresholds and dates.
- When an inconsistent formula is reported, look at its saved value as well as the formula. In the sample, C4 shows 1,200 where 600 was expected, which tells you the total is overstated.
- If a block was filled with a wrong formula and then one cell was corrected, the corrected cell is the one reported, because it is the minority. Read the example formula before changing anything.
- Insert a blank row or column between unrelated blocks of formulas. The check reads unbroken runs, so two tables pressed against each other can look like one block.
- Save the workbook in Excel just before auditing so the cached values reflect the current formulas.
Limits
Nothing is recalculated. If the file was saved with manual calculation switched on, saved values can be stale, and an error that a recalculation would produce (or clear) will not match what the audit shows.
An error caught by IFERROR or IFNA never reaches the cell, so it is not reported. Those wrappers can hide a broken lookup; search the Formula column of the report for them if that matters to you.
A number typed over one cell of a formula column is not reported as inconsistent, because that cell no longer holds a formula. It splits the run in two instead. Scan formula columns in Excel for cells shown without a formula if you suspect this.
Formulas inside conditional formatting rules, data validation lists, chart series and pivot calculated fields are not read. Defined names are checked only for links to other workbooks and for volatile functions.
A run needs three formulas side by side, and more than half of them must agree, before anything is reported. Two adjacent formulas, or a run where no pattern has a clear majority, are not judged.
Shared formulas are expanded by SheetJS by shifting the cell addresses in the stored text. In the rare case where a shared formula contains quoted text that looks like an address, such as "FY2024", the expanded copies can differ in that text and the run will not be judged.
Common errors and how to fix them
- The audit turns the file away, saying it is either a pre-2007 .xls or protected by a password to open.
- Workbooks saved before Excel 2007 and workbooks encrypted with a password to open are not ZIP archives, so no formula in them can be read. Clear the open password in Excel, or save the .xls in the .xlsx format, and audit the new copy. A password that only stops people editing a sheet does not get in the way: the formulas of a protected sheet are still stored as text and are audited like any others.
- "A CSV file stores values only, with no formulas to audit."
- A CSV export keeps the results of formulas but not the formulas themselves. Audit the .xlsx workbook the CSV came from.
- The audit stops because the workbook is larger than its 25 MB limit.
- Large workbooks are usually large because of one data sheet. Copy the calculation sheets into a new workbook, keep the data sheet out or trim it, save, and audit the smaller file.
- An external reference shows "(no link part found)".
- The formula uses an index such as [3] that has no matching part under xl/externalLinks, which happens when a file has been edited by tools that drop link parts. In Excel, open Data > Edit Links to see whether the link can be repaired or broken.
Best practices
- Keep rates, thresholds and dates in labelled input cells and refer to them, so the hard-coded list stays short and meaningful.
- Fill formulas down or across in one action instead of editing cells one by one; it keeps patterns intact and makes real exceptions stand out.
- Leave a blank row above a totals row only when the total is meant to be separate; otherwise keep it attached so its range is checked against the block.
- Replace OFFSET-based dynamic ranges with INDEX or with Excel tables where you can, and use INDIRECT only where nothing else will do.
- Run the audit before every hand-over and keep the report with the version you sent.
What the error values usually mean
Each error cell in the list carries a short reason. These are the usual causes, not certainties; the formula next to the error is where to start.
- #DIV/0! divides by zero or by an empty cell, often a denominator that has not been filled in yet.
- #N/A comes from a lookup that found no match, or from a cell where someone typed =NA() on purpose.
- #REF! means a row, column or sheet the formula used has been deleted; the formula text itself contains #REF!.
- #NAME? is a misspelt function, a deleted defined name, or a function the program that last saved the file does not know.
- #VALUE! is the wrong kind of input, such as text in a cell being multiplied.
- #SPILL! and #CALC! come from dynamic arrays: a spill range blocked by other cells, or a FILTER with no matches and no if_empty argument.
Why 0 and 1 are not counted
Zero and one appear in formulas for structural reasons far more often than as business numbers: the last argument of VLOOKUP and MATCH, OFFSET with no shift, multiplying by 1 to turn text into a number, or 1 minus a percentage. Listing them would bury the numbers that matter. Every other numeric literal is listed, including small integers inside ROUND, INDEX and VLOOKUP, because a column number typed into a lookup breaks just as silently when someone inserts a column.
Where the workbook is read
The file is unzipped and parsed by this browser tab with JSZip and SheetJS, and the reports are built in the same tab and handed to your browser as downloads. Once the audit has finished, the page holds on to the list of findings and the file name, which is all it needs to write either report again, and keeps no reference to the workbook itself. Choosing another file replaces the findings.
Frequently asked questions
Does the audit change my workbook?
No. It only reads the file. The reports are new files; the workbook you picked is not modified or rewritten.
Why is a correct formula reported as inconsistent?
Because most of its neighbours follow a different pattern. If the majority is wrong, the one correct cell is the odd one out. The finding names a matching neighbour so you can compare the two and decide.
Is every volatile function a problem?
No. TODAY in a report date or one RAND in a simulation is normal. Volatile functions matter when there are thousands of them, or when OFFSET and INDIRECT sit under large ranges, because every edit anywhere makes Excel recalculate all of them.
Will it find links hidden in defined names?
Yes. A defined name that points at another workbook is listed at workbook level, and every formula that uses the name is listed as an external reference with the name it goes through.
Can it audit .ods or Google Sheets files?
Not directly. Download or save the spreadsheet as .xlsx first; the audit then reads the formulas that the export wrote.