We've all been there — a formula that should work but throws #VALUE!, #REF!, #N/A, or #NAME?. The usual response is to stare at nested parentheses for 30 minutes, searching "Excel #VALUE error" on Google, and landing on a Microsoft Support page that lists every possible cause without telling you which one applies to your specific formula.
Claude AI changes that workflow. Instead of reading generic docs, you paste your exact formula, describe your data layout, and Claude tells you the specific cause and the corrected formula — usually in under a minute. This tutorial shows you the diagnostic format that gets the best results, walks through real examples for each major error code, and covers the cases where Claude's first answer might need a follow-up.
This works for all Excel error codes, logic errors (wrong result with no error code), nested formula breakdowns, and Google Sheets formulas too.
Prerequisites
- A Claude account at claude.ai — free tier is sufficient for all formula debugging.
- The broken formula copied from Excel (use the formula bar, not a screenshot).
- The error code or a description of the wrong result.
Excel Error Reference
Every error code points to a specific class of problem. Knowing which bucket yours falls into helps you give Claude a better prompt.
| Error | Meaning | Most Common Cause |
|---|---|---|
#VALUE! | Wrong data type in argument | Text where a number is expected; invisible spaces; dates stored as text |
#REF! | Invalid cell reference | Deleted row/column that the formula pointed to; VLOOKUP column index larger than the lookup range |
#N/A | Value not found | Trailing space in lookup value; number-stored-as-text mismatch; value genuinely absent |
#NAME? | Unrecognised name | Typo in function name; text not wrapped in quotes; function not available in your Excel version |
#DIV/0! | Division by zero or blank | Denominator cell is empty or zero; average of an empty range |
#NUM! | Invalid numeric result | Negative under SQRT; result too large for Excel to store; impossible iteration |
#SPILL! | Dynamic array blocked | A merged cell or non-blank cell sits in the spill range; see spill error guide |
#CIRC / circular | Formula references itself | Cell references its own row/column; accidental self-reference in a SUM range |
The Diagnostic Format That Gets the Best Results
The more specific context you give Claude, the more accurate the fix. Use this template:
"This Excel formula gives me [error code / wrong result]:
[paste your formula exactly]
Column A: [what it contains, data type]
Column B: [what it contains, data type]
Expected result: [what you want the formula to return]
Actual result: [what it shows now]"
If the formula references another sheet, say so: "The lookup range is on Sheet2, column B contains SKU codes as text (not numbers), and column D contains prices as numbers."
Real Diagnostic Examples
Error 1: #N/A in VLOOKUP (most common support question)
Prompt to Claude:
"This formula returns #N/A even though I can see the value in my data:
=VLOOKUP(A2, Sheet2!B:D, 3, FALSE)
A2 contains the text 'Product-001'.
Sheet2 column B contains product codes. I can see 'Product-001' in that column.
I want the formula to return the price from column D."
What Claude diagnoses: The three most common causes are (1) trailing spaces in either the lookup value or the source data — fix with =VLOOKUP(TRIM(A2), Sheet2!B:D, 3, FALSE); (2) the source data stores codes as numbers while A2 stores them as text — fix with =VLOOKUP(TEXT(A2,"0"), Sheet2!B:D, 3, FALSE); or (3) the lookup value is not in the first column of the range (you are looking in column B but Product-001 is actually in column A). Claude will ask which applies and return the corrected formula.
Beginner pitfall: Switching to XLOOKUP avoids most of these issues — see VLOOKUP vs XLOOKUP for the comparison.
Error 2: #VALUE! in a date formula
Prompt to Claude:
"=DATEDIF(A2, B2, 'y') gives #VALUE! error.
A2 = 15/01/2024, B2 = 20/03/2026.
I want the number of full years between the two dates."
What Claude diagnoses: Straight quotes ('y') are used instead of double quotes ("y") — a copy-paste artefact from web pages or Word. Corrected formula: =DATEDIF(A2, B2, "y"). Claude will also warn that DATEDIF is undocumented in newer Excel versions and suggest =YEAR(B2)-YEAR(A2) as the safer alternative.
Error 3: #REF! after deleting a column
Prompt to Claude:
"My VLOOKUP started returning #REF! after I deleted column C from my sheet.
Original formula was: =VLOOKUP(A2, B:E, 4, FALSE)
I deleted column C. Now the formula shows #REF!."
What Claude diagnoses: Deleting column C shrinks the lookup range (B:E becomes B:D) so column index 4 now falls outside it. Fix: change the column index to 3, or rewrite as =XLOOKUP(A2, B:B, D:D) which uses a return range instead of an index number and survives column deletions.
Error 4: #SPILL! from a dynamic array formula
Prompt to Claude:
"=UNIQUE(A2:A200) gives #SPILL! error. I can't see what's in the spill range."
What Claude diagnoses: Something is blocking the cells below the formula cell — a merged cell, a value in an adjacent row, or a hidden character. Ask Claude: "How do I find and clear a #SPILL! block?" and it will walk you through selecting the spill range via the formula's blue border, then clearing the obstruction. Full details in the #SPILL! error guide.
Error 5: No error code — wrong result
Prompt to Claude:
"This SUMIFS formula returns 0, but there should be matching values:
=SUMIFS(C:C, A:A, "London", B:B, "Q1")
Column A contains city names, Column B contains quarter labels (Q1, Q2 etc.), Column C contains revenue numbers.
I can see rows with London and Q1 but the result is 0."
What Claude diagnoses: The most likely cause is that column B actually contains "Q1 2026" or " Q1" (with a leading space) rather than the bare "Q1" the formula expects. Claude will suggest =SUMIFS(C:C, A:A, "*London*", B:B, "*Q1*") as a wildcard version to confirm, then help tighten the criteria once the mismatch is confirmed.
Debugging Nested Formulas
For complex formulas like =IF(AND(ISNUMBER(A2),A2>0),VLOOKUP(A2,Sheet2!B:D,3,FALSE)/SUM(C:C),"") it's impossible to read the error by eye. Ask Claude to break it down:
"Can you break this formula down step by step, evaluate what each nested function returns, and tell me which layer is producing the error?"
Claude evaluates inside-out: it checks ISNUMBER(A2) first, then AND(), then the VLOOKUP branch, then the division — narrating what each level should return given your data. This usually pinpoints the exact layer that breaks within one or two replies.
You can also use Excel's own Evaluate Formula tool (Formulas tab → Evaluate Formula) to step through the formula visually; Claude is faster for complex cases where you need an explanation, not just a step trace.
Preventive Debugging Habits
- Check for hidden spaces first —
=LEN(A2)returning a higher number than expected means invisible characters are present.=TRIM(A2)removes them. Full data cleaning workflow: how to clean messy data in Excel. - Verify data types with ISNUMBER / ISTEXT — A column that looks like numbers but returns TRUE on
=ISTEXT(A2)will break any arithmetic formula silently. - Use IFERROR as a canary, not a fix —
=IFERROR(your_formula, "ERROR")makes errors visible during testing, but do not leave it in production; it masks real data problems. - Build incrementally — Test each nested function in a separate cell before combining. The advanced formulas guide demonstrates this for each function family.
- Prevent bad inputs at the source — Data validation dropdowns stop users from entering text in number-only columns, eliminating the root cause of most #VALUE! errors.
- Convert text-numbers to real numbers before lookup — Paste Special → Values → Multiply by 1, or use the
=VALUE()function wrapper, before running VLOOKUP/XLOOKUP against the column.
When to Use Claude vs Excel's Native Tools
| Situation | Best tool |
|---|---|
| You can see the formula is wrong but don't know which part | Claude — paste and ask for layer-by-layer breakdown |
| You need to watch each nested evaluation step visually | Excel Evaluate Formula (Formulas tab) |
| You need to trace which cells feed into an error | Excel Trace Precedents / Dependents (Formulas tab) — see formula auditing guide |
| Claude's fix still doesn't work | Paste the corrected formula + new error back to Claude for a second pass |
| Wrong result with no error code | Claude — describe expected vs actual and data layout |
Troubleshooting
-
Claude gave me a fixed formula but I still get the same error
The most likely cause is that Claude made an assumption about your data layout that was wrong. Reply with: "The fix still gives #N/A. Here is a sample row: A2='P-001', Sheet2 B2='P-001 '" — the extra trailing space in Sheet2 will immediately surface. The second pass is almost always correct once the actual data values are included. -
Claude's formula uses XLOOKUP but I don't have it
XLOOKUP requires Excel 365 or Excel 2021. If you are on Excel 2019 or earlier, reply: "I am on Excel 2019, please use INDEX MATCH instead." Claude will rewrite the formula without XLOOKUP. -
The formula works in one cell but breaks when I copy it down
This is usually a missing dollar sign in a reference that should be absolute — e.g.B:Daccidentally becomingB2:D2when dragged. Ask Claude: "The formula works in row 2 but breaks in row 5. Here is the row-5 version: [paste]." Claude will spot the shifted reference instantly. -
Circular reference warning and I can't find it
Go to Formulas → Error Checking → Circular References — Excel lists every cell in the chain. Paste the formula from the listed cell into Claude with the message "This formula is flagged as a circular reference. What is the cycle and how do I break it?" -
Claude doesn't understand my formula because it uses a custom LAMBDA
Paste the LAMBDA definition as well as the formula that calls it. Claude handles LAMBDA, LET, and named ranges — it just needs the full definition to reason about the logic.
FAQ
- Can Claude diagnose wrong results as well as error codes?
- Yes. Describe the expected output and the actual output, then paste the formula and explain the data layout. Claude identifies logic errors — a SUMIFS range offset by one column, an IF condition evaluating the wrong branch, a percentage formula forgetting to divide by 100 — even when Excel shows no error code at all.
- What information should I give Claude to get the best fix?
- Include: (1) the exact formula as it appears in the formula bar, (2) the error code or wrong result, (3) column headers and one or two sample data rows, and (4) what the formula should return. Data types matter — state whether each column contains text, numbers, dates, or currency.
- Can Claude fix VLOOKUP returning #N/A even though the value exists?
- Yes — this is one of Claude's most reliable fixes. The usual culprits are trailing spaces (fix: TRIM the lookup value), number-stored-as-text mismatch (fix: VALUE wrapper), or the lookup value being in the wrong column of the range. Claude identifies which applies and often suggests switching to XLOOKUP which avoids these pitfalls by design.
- Can Claude diagnose formulas in Google Sheets too?
- Yes. Most formulas are identical between Excel and Sheets. Tell Claude you are in Google Sheets and it will avoid Excel-only functions (XLOOKUP is not in Sheets) and use ARRAYFORMULA or QUERY where appropriate.
- Can I ask Claude about a formula error in a screenshot?
- You can upload the screenshot, but Claude's fix will be more accurate if you also paste the formula as text. Screenshots can't be copy-pasted, so Claude has to re-type the formula — and small OCR misreads will lead to wrong output. Always include the text of the formula alongside any image.
Sources
- Microsoft — Detect formula errors in Excel
- Anthropic Help Centre — Use Claude for Excel
- Microsoft — Formulas not updating automatically in Excel
Related tutorials
- Excel Formulas & AI Hub — the canonical Excel + AI reference on this site
- How to Use Claude AI to Write Excel Formulas Instantly
- How to Use Claude AI to Write Excel Macros and VBA Code
- How to Audit Formulas in Excel: Trace Precedents, Dependents, and Error Sources
- Run a Free Local AI in VS Code with Gemma 4 — for AI-assisted coding beyond Excel