Spreadsheet Errors Explained: Fix #N/A, #REF! and #VALUE!

Each of the three errors points to a different problem. #N/A means a lookup found nothing to return. #REF! means a formula refers to a cell, range or sheet that no longer exists in the form it was written. #VALUE! means a formula received a value of the wrong type, most often text where it expected a number. Read the error code first, because the code tells you where to look, and the fix follows from that.

What the three errors actually mean

Spreadsheet programs use these codes to report that a formula could not produce a result. The code is not a judgement on the whole sheet. It marks one cell, and every cell that depends on it will usually show the same error too.

#N/A: a value that cannot be found

#N/A stands for “not available”. It appears most often in lookup functions such as VLOOKUP, XLOOKUP, MATCH and HLOOKUP when the search value does not exist in the range being searched. A customer ID typed as “C-1042” will not match “C-1042 ” with a trailing space, and the lookup returns #N/A.

Some people also type =NA() on purpose. Charts treat #N/A as a gap rather than a zero, so a deliberate #N/A keeps a line chart from dropping to nothing where data is missing.

#REF!: a reference that no longer points anywhere

#REF! means “reference error”. A formula holds a reference to a cell or range, and that reference has become invalid. The usual triggers are:

  • A row, column or sheet that the formula pointed to was deleted.
  • A cut and paste moved the source cells, and the formula could not follow in the way you expected.
  • A VLOOKUP asked for a column number greater than the number of columns in its table array.
  • INDIRECT was given text that does not describe a valid address, such as a sheet name that has been renamed.

#VALUE!: the wrong kind of value

#VALUE! means the formula was given a value it cannot use. The commonest case is arithmetic on text. If B2 contains the word “twelve” and you write =B2*2, the result is #VALUE!. The less obvious case is a number that looks like a number but is stored as text, often because it came from a system export or a web page with a leading apostrophe or a non-breaking space.

The following table compares the three.

ErrorMeaningTypical triggerFirst place to lookUsual fix
#N/ALookup found no matchTrailing spaces, typos, wrong data type in the lookup keyThe lookup value and the lookup column side by sideClean the key, check match type, or handle the miss with IFNA
#REF!Reference is invalidDeleted row, column or sheet; column index beyond range; bad INDIRECT textThe formula bar, then Trace PrecedentsRewrite the reference or restore the deleted source
#VALUE!Wrong data typeText in arithmetic; stored-as-text numbers; mismatched argument shapesCell format and the raw content of each inputConvert the text to a number or correct the argument
Lapis Ledger Annual Budget

Skip the setup

Lapis Ledger Annual Budget

Monthly and annual budget tabs for Excel and Google Sheets, with category totals that add themselves up.

See it on Taskdale →

A one-minute diagnostic workflow

Work through the steps below in order when an error appears. Most errors are resolved at step three or four, and the workflow stops you from changing formulas that were never broken.

  1. Click the error cell and read the code. Do not start editing yet.
  2. Look at the formula bar and identify each input. Write down the cell or range each part refers to.
  3. Check each input’s actual content, not its displayed content. Click into the cell, or use =LEN(A1) to count characters. A value that should be “C-1042” with a length of 7 and a length of 8 is a whitespace problem.
  4. Use the trace tools. In Excel, Formulas, then Trace Precedents shows which cells feed the formula. Formulas, then Evaluate Formula steps through the calculation one part at a time and shows where the error first appears.
  5. Fix the source, not the symptom. If the source is a text number, convert it at the source where possible. Wrapping the formula in an error handler should come last, not first.
  6. Check the dependent cells. Once the error source is fixed, filter or scan the columns that use it, because one repaired cell may have fed a whole chain.

Fixing #N/A

Most #N/A errors in real workbooks come from three causes: hidden characters, the wrong match type, or a value that genuinely is not in the list.

Check the lookup value for hidden characters

Hidden characters are the most common cause and the hardest to spot by eye. Trailing spaces, leading spaces and non-breaking spaces (character code 160, often pasted from web pages or accounting software) all cause a miss.

TRIM removes ordinary spaces. It does not remove non-breaking spaces in Excel, so use a combined formula where the source is dirty:

=TRIM(SUBSTITUTE(A2,CHAR(160),” “))

This replaces each non-breaking space with an ordinary space, then trims the result. Apply it to the lookup key, and optionally to the lookup column if that column was also pasted in from the same source.

Use exact match

VLOOKUP’s fourth argument decides how it matches. If you omit it, or set it to TRUE, the function performs an approximate match. That can return a wrong answer rather than an error, which is worse. Set it to FALSE for exact matching:

=VLOOKUP(B2, Customers!A:C, 2, FALSE)

XLOOKUP, available in Excel 2021, Microsoft 365 and current Google Sheets, defaults to exact matching, which is one reason to prefer it for new work. Its fifth argument can return a custom message instead of #N/A:

=XLOOKUP(TRIM(B2), Customers!A:A, Customers!B:B, “Not found”)

Handle expected misses with IFNA

Some misses are normal. A new customer may not yet be on the list, and a report should still calculate. In that case, handle only the #N/A condition:

=IFNA(XLOOKUP(TRIM(B2), Customers!A:A, Customers!B:B), “Not on list”)

IFNA catches #N/A and nothing else. If you wrap the same formula in IFERROR, a #REF! or #VALUE! caused by a real fault would be hidden as well. The trade-off is covered in more detail below.

Fixing #REF!

#REF! errors are structural. A formula is pointing at something that has moved or disappeared, so you need to find the broken reference and decide what it should point to.

Find the deleted or moved reference

Open the formula bar and look for the text #REF! inside the formula itself. A formula that once read =Sales!B2 will show =#REF!B2 if the Sales sheet was deleted. Excel does not reconnect it automatically, even if you recreate a sheet with the same name.

To find all affected cells, use Find (Ctrl+F in Excel) and search within formulas for “#REF!”. Then rebuild the reference or restore the deleted source from a backup or version history.

Check the column index in lookups

VLOOKUP and HLOOKUP return #REF! when the index number is larger than the table they search. Suppose the table is Customers!A:B, which has two columns, and the formula asks for column 3:

=VLOOKUP(B2, Customers!A:B, 3, FALSE)

This is one of the most common causes of #REF! after someone deletes a column from a source sheet. The fix is either to correct the index or, better, to stop depending on a column number at all. INDEX and MATCH, or XLOOKUP, refer to a named column directly, so deleting a column elsewhere does not silently shift the answer.

Fixing #VALUE!

#VALUE! errors have three common causes: text where a number is expected, numbers stored as text, and arguments of the wrong shape or type.

Convert numbers stored as text

A number stored as text looks correct in the cell, often aligns to the left rather than the right, and sometimes shows a small green triangle in Excel. Arithmetic on it may work in some places and fail in others. SUM ignores text inside a range, so a total can look plausible while leaving out values. Adding two cells with the + operator fails with #VALUE! instead.

Convert the values at source where you can. In Excel, select the column, choose Data, then Text to Columns, then Finish. This re-parses the cells as numbers. For a formula-based fix, use VALUE:

=VALUE(TRIM(SUBSTITUTE(D2,CHAR(160),””)))

Be aware that VALUE follows the regional settings of the computer. In a locale that uses a comma as the decimal separator, the text “12.50” may convert to a different number or to #VALUE!. If a workbook is shared across locales, convert the data once and store numbers as numbers.

Check argument types and shapes

Some functions reject arguments of the wrong type. Dates stored as text will not behave as dates in DATEDIF or in a date comparison. A function that expects a single value but receives a range may return #VALUE! in older Excel, or spill an array in newer versions, depending on the formula and the setting.

Mismatched array sizes are also a source of trouble. When an operation combines two arrays of different dimensions, the result is often an error, and the exact code depends on the function involved. The fix is to make both inputs the same shape, usually by aligning the ranges to the same rows and columns.

Small Business CEO Dashboard

Ready-made template

Small Business CEO Dashboard

Sales, costs, cash and targets on one screen. The formulas are already built, so you type the numbers and the dashboard does the rest.

See it on Taskdale →

The trade-off of hiding errors with IFERROR and IFNA

Error-handling functions make reports look tidy. They also make it easier to miss real faults, and that cost is the reason many analysts treat them with caution.

IFERROR returns a replacement value for any error. =IFERROR(C2*D2, 0) turns a broken price into a zero total. The sheet looks clean, and the total is now understated without any warning. IFNA is narrower, because it catches only #N/A, and it is usually the safer choice for lookups.

A practical rule applies. Use IFNA when a miss is an expected business outcome, such as a missing optional record. Use IFERROR only at the final presentation layer, after the data has been checked. Do not use it inside calculation chains where an error should stop the process and draw attention.

Fixing the source has its own costs. Cleaning a few thousand text values by hand takes time, while a formula wrapper takes seconds. The cost of the wrapper is that the bad data stays in the file. Over time, the sheet becomes harder to audit. Choose the approach based on how long the file will live and who else will rely on it.

Common mistakes

Several habits create most of the errors described above.

  • Lookups on keys stored in different formats. A number 1042 in one sheet and the text “1042” in another will not match. Check the data type of both sides.
  • Omitting the match type in VLOOKUP. The default approximate match can return a plausible but wrong value, which is harder to catch than an error.
  • Using whole-column references everywhere. References such as A:A are convenient, but they slow large workbooks. Use defined ranges or table references where the data is large and stable.
  • Deleting rows or columns without checking dependencies. Select the column, use Trace Dependents, and confirm nothing important points to it before deleting.
  • Pasting formulas with cut instead of copy. Cutting a cell moves its dependents with it in some cases and breaks references in others. Copy the cell, then paste values where the result should be fixed.
  • Wrapping every formula in IFERROR by default. This hides faults before anyone sees them.

Worked example: repairing an orders sheet

Suppose you manage a small orders workbook. The Orders sheet has these columns: Order ID in A, Customer ID in B, Quantity in C, Unit price in D, Line total in E, and Customer name in F. The Customers sheet has Customer ID in A, Customer name in B and Region in C.

The first version of the sheet has three faults.

Fault one: row 4 shows #N/A in column F. The customer ID in B4 is “C-1042 ” with a trailing space, copied from an email. Checking =LEN(B4) returns 7, while the ID “C-1042” has length 6. The fix is to clean the key inside the lookup:

=IFNA(XLOOKUP(TRIM(B4), Customers!A:A, Customers!B:B), “Not on list”)

TRIM handles the trailing space. IFNA handles the genuine case where a new customer is not yet on the list, and returns a visible label rather than an error.

Fault two: row 7 shows #VALUE! in column E. The formula in E7 is =C7D7. The unit price in D7 is the text “12.50”, imported from a system export. The formula cannot multiply text, so it fails. Select column D, choose Data, then Text to Columns, then Finish. The text becomes the number 12.50, and E7 recalculates to a total. For a sheet that cannot be edited at source, the formula =C7VALUE(TRIM(D7)) gives the same result.

Fault three: column F shows #REF! for every row after a previous edit. Earlier, someone used a VLOOKUP to fetch the region from the Customers sheet, written as =VLOOKUP(B2, Customers!A:C, 3, FALSE). Then a colleague deleted the old Customer Name column on the Customers sheet, so the table became two columns wide. The index 3 now points past the table, and the formula returns #REF!.

The repair has two parts. First, rewrite the formula to refer to the column by name using INDEX and MATCH, which does not depend on the number of columns in the table:

=INDEX(Customers!C:C, MATCH(TRIM(B2), Customers!A:A, 0))

Second, confirm that no other formula in the workbook uses a numeric column index against the same table. Use Find to search formulas for “Customers!A:C” and review every result.

After these three changes, run a check across the whole sheet. Filter each column for errors, or use =SUMPRODUCT(–ISERROR(A2:F500)) to count them. A result of zero confirms that the fixes held. Keep a note of what was changed and why, because the next person to open the file will otherwise repeat the same faults.

Checklist for the next error

Use this short list when an error appears in any workbook.

  • Read the code and identify which of the three causes it points to.
  • Check each input’s raw content, including length and hidden characters.
  • Confirm the match type on every lookup is exact unless approximate matching is deliberate.
  • Convert text numbers at source, and treat the regional setting as a variable.
  • Trace precedents before deleting anything, and avoid numeric column indexes where a named lookup will do.
  • Use IFNA for expected misses, and reserve IFERROR for the final presentation layer.
  • Count errors after every data refresh, so faults are found on the day they appear rather than in the monthly report.
Binsight Inventory Spreadsheet

Get the finished file

Binsight Inventory Spreadsheet

Stock in, stock out and reorder alerts that turn red before you run out. Uses lookups and conditional formatting.

See it on Taskdale →

Scroll to Top