Expert guide

Fix Excel Formula Errors with AI: #N/A, #VALUE!, #SPILL! and More

Find the cause, not just a formula that makes the error disappear

Short answer: each Excel error code points to a specific kind of problem: #N/A means a lookup found no match, #VALUE! means the wrong data type, #REF! means a deleted reference, #SPILL! means a blocked dynamic array, #NAME? means an unknown function or name. Use Evaluate Formula to find the failing part, then fix the data, not the symptom. When asking AI for help, paste the formula, the error, sample rows and the expected result. For workbooks that break every month, see Excel troubleshooting.

Formula errors are not random. Each code tells you which kind of thing went wrong, and once you know the pattern most errors take a minute to fix. AI assistants are useful here, but only if you ask them to diagnose rather than to make the error go away. "Make this formula work" often produces IFERROR(formula, 0), which turns a visible problem into an invisible wrong number.

What Each Error Actually Means

ErrorWhat Excel is telling youMost common real cause
#N/AA lookup found no matchTrailing spaces, numbers stored as text, missing record
#VALUE!An argument is the wrong typeText in a cell used in arithmetic, or a date stored as text
#REF!A reference no longer existsRows, columns or sheets deleted after the formula was written
#NAME?Excel does not recognise a wordMisspelled function, missing quotes around text, or a function your version lacks
#DIV/0!Division by zero or blankRatios on rows with no base value yet
#SPILL!A dynamic array cannot spillSomething is in the way, merged cells, or the formula is inside a Table
#NUM!A number is invalid for the calculationIRR or RATE cannot converge, or result too large
#CALC!The calculation engine hit an unsupported caseFILTER returned nothing with no if_empty argument; nested arrays
####Not an error: the column is too narrowWiden the column, or a negative date/time

Fixing #N/A in Lookups

#N/A is the error people search for most, and it is nearly always a data mismatch, not a formula problem. Diagnose it in this order:

  • Compare directly

    In a spare cell type =A2=Customers!A15 pointing at the value you think should match. FALSE confirms they differ.

  • Check length

    =LEN(A2) and =LEN(Customers!A15). A difference means hidden spaces or characters.

  • Check type

    =ISNUMBER(A2) and =ISNUMBER(Customers!A15). Numbers on one side and text on the other never match.

  • Check match mode

    VLOOKUP's last argument must be FALSE (or 0) for exact match. XLOOKUP defaults to exact match.

Robust lookup that tolerates spaces and text-numbers:
=XLOOKUP(TRIM(A2)&"",
         TRIM(Customers!A2:A5000)&"",
         Customers!D2:D5000,
         "Not found")

Appending &"" converts both sides to text so 1001 and "1001" match. It is a good patch; the real fix is cleaning the source column once.

Fixing #VALUE!

Find the cell that is not what the formula expects. Select the formula, then Formulas → Evaluate Formula, and click Evaluate until the error appears. The step just before it shows which reference holds text. Common culprits: amounts with a currency symbol typed in, dates pasted from a website, and cells containing a single space.

Count cells that look like numbers but are text:
=SUMPRODUCT(--ISTEXT(F2:F5000), --(F2:F5000<>""))

Convert in place: select the column → Data → Text to Columns → Finish

Fixing #REF!

#REF! means part of the formula pointed to something that was deleted. Press F2 to see which argument shows #REF! literally inside the formula. You cannot recover the original target from the formula itself; use Undo if it just happened, or check a previous version in OneDrive or SharePoint version history. To prevent it, use Excel Tables and structured references, which adjust when rows and columns change, or XLOOKUP instead of VLOOKUP with a hard-coded column number.

Fixing #SPILL!

  • Click the error and select the warning icon; Excel names the blocking cell.

  • Clear any values, even spaces, in the spill range.

  • Unmerge cells in the spill range.

  • Move the formula out of an Excel Table; spilled arrays are not allowed inside Tables.

  • If the result is legitimately huge (whole-column references), restrict the range.

Fixing #NAME?

Check spelling first. Then check that text inside the formula is in double quotes, that named ranges exist (Formulas → Name Manager), and that the function exists in your version. XLOOKUP, FILTER, LET, TEXTSPLIT, VSTACK and the REGEX functions return #NAME? in Excel 2016 and 2019. If a colleague with Microsoft 365 built the file, everyone on older versions will see #NAME?.

Circular References

A circular reference warning means a formula depends, directly or through other cells, on its own result. Formulas → Error Checking → Circular References lists the cells involved. Occasionally it is intentional, as in some interest calculations, and iterative calculation is enabled on purpose. Usually it is an accident, such as a total row included in its own SUM range.

Prompts That Get AI to Diagnose, Not Patch

Excel 365, Windows. This formula returns #N/A for about 30% of rows:
=XLOOKUP(B2, Products!A:A, Products!C:C)
B2 values look like: 10045, 10046, A-2201
Products!A values look like: 10045, 10046, A-2201
Expected: the price from Products!C.
List the likely causes in order of probability, how to test each one
with a formula, and the fix. Do not just wrap it in IFERROR.
  • Here is a formula and its error. Walk through how Excel evaluates it step by step and say where it fails.

  • Give me three tests I can type into spare cells to find out why these two values do not match.

  • Rewrite this formula so the error is replaced only when the lookup is legitimately missing, and flag anything else.

  • This workbook has 400 #REF! errors after someone deleted a sheet. How do I find all of them and what are my recovery options?

When Errors Are a Symptom of a Bigger Problem

If errors reappear every time new data is pasted in, the workbook design is the problem: hard-coded ranges, manual copy-paste steps, lookups against lists maintained by hand. If the file also crashes, is very slow, or will not open properly, that is a different issue covered under Excel file repair. Our Excel consultants rebuild fragile workbooks with tables, validated inputs and automated imports so the errors stop at the source. For writing new formulas with AI, see using ChatGPT to write Excel formulas.

FAQ

Excel formula errors FAQ

Quick answers to the errors people search for most

Usually the two values only look the same. Common causes are a trailing space, a number stored as text on one side and as a number on the other, a non-breaking space from a web export, or a different date format. Test with =A2=Sheet2!A5; if it returns FALSE, clean one side with TRIM, VALUE or SUBSTITUTE(A2,CHAR(160),"").

A dynamic array formula such as FILTER, UNIQUE or SORT wants to return several values but something is in the way: a non-empty cell, merged cells, or an Excel Table, which cannot hold spilled results. Clear the cells in the spill range, unmerge, or move the formula outside the table.

Paste the exact formula, the exact error, two or three sample input rows, and the result you expected. Say which Excel version you use. Ask the AI to list likely causes in order and how to test each, rather than just rewriting the formula, so you fix the data problem instead of hiding it.

Only when an error is an expected, harmless outcome, such as a lookup for an optional code. Wrapping everything in IFERROR hides real problems: a typo, a missing customer, a broken link. A report full of zeros instead of errors looks correct and is not.

The cell is formatted as Text, or the formula starts with a space or an apostrophe. Change the format to General, then press F2 and Enter. If many cells are affected, use Find and Replace to replace = with = which forces Excel to re-enter them.