IFERROR and Formula Errors: How to Fix #N/A and #DIV/0!

#N/A and #DIV/0! are signals that a formula cannot produce a valid answer, usually because of a lookup that found nothing or a division by zero. IFERROR and IFNA can hide these signals, which is useful only after you know what is causing them.

Glossary and Overview

SOP 1.1: Error values covered in this guide

  • #DIV/0!: A formula tried to divide by zero or by an empty cell.
  • #N/A: A value is not available. Most often a lookup function found no exact match.
  • #VALUE!: A formula received a value of the wrong type, such as text where a number was expected.
  • #REF!: A formula refers to a cell or range that no longer exists, usually after a deletion.
  • #NAME?: Excel or Google Sheets does not recognise a function name or a range name, often because of a typing error.
  • #NUM!: A calculation produced a number that is out of range, for example a square root of a negative value.

SOP 1.2: Error-handling functions

  • IFERROR(value, value_if_error): Returns the second argument when the first produces any error value.
  • IFNA(value, value_if_na): Returns the second argument only when the first produces #N/A. Other errors pass through.
  • ISERROR(value): Returns TRUE for any error value, including #N/A. Used inside IF to build custom logic.
  • ISNA(value): Returns TRUE only for #N/A.
  • IF with a condition on the input: Tests the input before the calculation runs, for example IF(C2=0, “”, B2/C2). This prevents the error instead of catching it.
  • XLOOKUP with its if_not_found argument: Handles a failed lookup inside the lookup itself, without a wrapper.
Binsight Inventory Spreadsheet

Skip the setup

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 →

Resolving #DIV/0!

SOP 2.1: Confirm the cause

  1. Click the cell showing #DIV/0! and read the formula in the formula bar.
  2. Identify the denominator, which is the value after the division sign or inside the second argument of a function such as AVERAGE.
  3. Click the denominator cell and check its value. A blank cell, a cell containing 0, or a cell containing text that converts to zero will all produce this error.
  4. Trace the denominator back. If it is a formula, repeat steps 1 to 3 on that cell until you reach a source value.
  5. Decide whether the zero is a real figure or a gap in the data. A zero headcount in a branch that has closed is real. A blank headcount for a branch that still operates is a data gap.

SOP 2.2: Prevent the error at the source

When the zero or blank is a legitimate state, guard the division with a condition on the input:

=IF(C2=0, "", B2/C2)

In this formula, a blank cell in C2 also evaluates as equal to zero, so the test catches both. The result is an empty string rather than an error, which leaves the cell visibly blank and does not distort totals.

If you want a visible marker instead of a blank, return text such as “No headcount” or “n/a”. Keep the marker consistent across the workbook so that filters and counts behave predictably.

SOP 2.3: Use IFERROR only when the blank result is correct

=IFERROR(B2/C2, "")

This version also works, but it catches every error from the division, not just #DIV/0!. If the cells B2 or C2 later contain text because someone pasted a note into them, the formula will return a blank and the problem will be silent. The conditional version in SOP 2.2 fails loudly on a different error type, which is usually what you want.

Resolving #N/A

SOP 3.1: Check the lookup value

Most #N/A results from lookups come from a lookup value that looks identical to the target but is not. Check these conditions in order:

  1. Trailing or leading spaces. “East ” with a space does not match “East”. Use TRIM to test: =LEN(A2) shows a length greater than expected.
  2. Numbers stored as text. A product code 1042 stored as text does not match a numeric 1042 in the lookup table. A green triangle in the corner of a cell often signals this.
  3. Non-printing characters. Text copied from web pages or exported systems can contain characters that TRIM does not remove. CLEAN removes many of them, and combining TRIM and CLEAN handles most cases.
  4. Different dates. A date with a time component does not match the same date without one.

SOP 3.2: Check the match type

  • VLOOKUP with FALSE requests an exact match. Using TRUE, or omitting the argument, requests an approximate match on a sorted list. An approximate match can return a wrong answer silently rather than #N/A, so always set the fourth argument to FALSE for codes, names and identifiers.
  • MATCH with 0 requests an exact match. MATCH with 1 or -1 expects sorted data and returns the nearest value.
  • XLOOKUP defaults to an exact match, which is one reason to prefer it where it is available.

SOP 3.3: Check the source range

  1. For VLOOKUP, confirm that the lookup column is the leftmost column of the table range. VLOOKUP cannot look left.
  2. Confirm the table range covers all the rows. A range such as A2:B50 will return #N/A for a key stored in row 51.
  3. Use whole-column references such as Regions!A:B, or a named table, so that new rows are included without editing the formula.
  4. Confirm that the lookup table has not been sorted or filtered in a way that hides the target row. Filtered rows are still searched in VLOOKUP, but a filter on the source sheet can make a row appear to be missing.

SOP 3.4: Accept the #N/A when it is correct

Sometimes the record genuinely does not exist. A new region has not been added to the mapping table, or a supplier has not been onboarded. In that case #N/A is the correct output. Replace it with a label that tells the reader what the gap means, such as “Unmapped”, and keep a list of those labels for follow-up. Do not hide the gap with a blank.

Choosing Between IFERROR, IFNA, ISERROR and ISNA

The table below sets out what each function catches and where it fits.

FunctionCatchesPasses throughTypical useRisk
IFERRORAll error valuesNothingWrapping a calculation where any failure has the same meaningHides #NAME?, #REF! and #VALUE! along with the error you expected
IFNA#N/A only#DIV/0!, #VALUE!, #REF!, #NAME?, #NUM!Lookups where a missing match is an expected outcomeHides a missing match that should have been investigated
ISERROR inside IFAll error values, tested explicitlyWhatever the IF branch returnsCustom logic that needs different outputs for different conditionsLonger formulas that are harder to audit
ISNA inside IF#N/A only, tested explicitlyWhatever the IF branch returnsBranching on a missing match while keeping other errors visibleSame audit cost as ISERROR
IF on the inputNothing, because it prevents the errorValid resultsDivision and other operations with a known invalid inputRequires you to anticipate every invalid input
XLOOKUP if_not_found#N/A from the lookup onlyOther errors from the argumentsLookups in Excel 2021, Excel 365 and Google SheetsNot available in Excel 2019 and earlier

Decision rules

  • Use IFNA for lookups where a missing match is a valid state, and keep the other errors visible.
  • Use IF on the input for divisions where a zero or blank denominator is a valid state.
  • Use IFERROR only where you have checked that every possible error inside the wrapped formula has the same meaning. This is rare in practice.
  • Use ISERROR or ISNA inside IF when the output must change depending on the type of error.
  • Avoid nesting several IFERROR functions. A chain of three or four means the underlying formula has not been understood, and the chain will hide the next problem.
Profit Loom Pricing Calculator

Ready-made template

Profit Loom Pricing Calculator

Work out cost, markup, margin and platform fees for each product, so every price you set leaves a profit.

See it on Taskdale →

Common Mistakes

SOP 5.1: Wrapping every formula in IFERROR

Applying IFERROR across a whole sheet makes the workbook look clean and removes every signal that something is wrong. The first genuine error, such as a deleted sheet causing #REF!, will then appear as a blank in a report that nobody questions. Apply error handling only to the specific formulas where you have confirmed the expected error.

SOP 5.2: Returning zero instead of blank

=IFERROR(B2/C2, 0) puts a zero into a column that is then averaged. The average of 30,000, 0 and 25,000 is 18,333, which looks like a real result but describes a dataset that has two valid values and one placeholder. Use an empty string or a labelled marker so that AVERAGE, which ignores text, produces the correct figure.

Note that AVERAGE ignores text values in ranges, while it treats a numeric zero as data.

SOP 5.3: Hiding #NAME? and #REF!

A typing error in a function name, such as SUMIF written as SUMIFS with the wrong arguments, produces #NAME? or #VALUE!. A wrapper that catches everything turns a broken formula into a plausible-looking number or blank. Use IFNA or explicit ISNA tests so that these errors remain visible.

SOP 5.4: Using an empty string in arithmetic

A formula that returns “” is text. Adding it to a number with the plus sign produces #VALUE!. SUM and AVERAGE ignore text in ranges, but a direct calculation such as =D2*1.2 fails. Check downstream formulas that reference a cell which may now contain “”.

SOP 5.5: Fixing the symptom and not the source

Wrapping the formula is faster than fixing the lookup key or the data entry process. The next person to edit the source data will not know that the error was being hidden, and the same gap will reappear in every new row. Record the root cause, fix it at source where possible, and only then add error handling.

Worked Example

SOP 8.1: Scenario

A regional sales workbook has two sheets. The Sales sheet has one row per branch with columns for region, revenue, headcount, revenue per head, and manager. The Regions sheet maps each region to a manager. The report needs revenue per head for every branch and the responsible manager, with no unexplained errors.

The first draft uses these formulas in row 2:

  • D2: =B2/C2
  • E2: =VLOOKUP(A2, Regions!A:B, 2, FALSE)

Across 14 rows, three cells in column D show #DIV/0! and two cells in column E show #N/A.

SOP 8.2: Diagnose the errors

  1. The three #DIV/0! cells sit in rows where column C is blank. Two of those branches have closed, and one is a new branch with no headcount entered yet.
  2. Of the two #N/A cells, one row contains “East ” with a trailing space in column A. The Regions sheet has “East” with no space. This is a data-entry problem, and it is the cause of the error.
  3. The other #N/A row contains “Central”, which is absent from the Regions sheet. The mapping was never added for this region. This is a genuine gap.

SOP 8.3: Apply the fixes

Apply the input guard to column D:

  • D2: =IF(C2=0, "", B2/C2)

Apply TRIM to the lookup key, and handle the genuinely missing mapping with a labelled fallback:

  • E2: =IFNA(VLOOKUP(TRIM(A2), Regions!A:B, 2, FALSE), "Unmapped")

Clean the source data by removing the trailing space from the cell in column A, so that TRIM is a safeguard rather than the only fix. Add the Central mapping to the Regions sheet, which removes the last genuine gap.

SOP 8.4: Results

MeasureBeforeAfter
Cells showing #DIV/0!30
Cells showing #N/A20
Cells showing a blank for no headcount03
Cells showing “Unmapped”00 (after adding Central)
Cells showing a manager name1114

Before the Central mapping was added, one row showed “Unmapped”. Once the mapping was added, the label cleared. The fallback remains in the formula so that any future unmapped region is flagged rather than producing an error.

SOP 8.5: Verify

  1. Filter column E for “Unmapped” and confirm that no rows remain.
  2. Add a check cell with =SUMPRODUCT(--ISERROR(D2:E15)) and confirm that it returns 0.
  3. Confirm that the average of column D excludes the three blank rows and matches a manual calculation over the eleven valid rows.

Checklist and Decision Rule

SOP 9.1: Pre-release checklist

  1. Identify the exact error type before applying any wrapper.
  2. Confirm whether the error reflects a data problem, a missing record, or a valid empty state.
  3. Fix the source data where the fault lies, including spaces, text-formatted numbers and absent mappings.
  4. Use an input condition for valid zeros and blanks in divisions.
  5. Use IFNA for lookups where a missing match is expected, and label the fallback.
  6. Use IFERROR only where every wrapped error has the same meaning.
  7. Return a blank or a labelled marker, never a zero, where the output feeds an average.
  8. Add an error-count check to any sheet that feeds a report.
  9. Document each wrapper and the error it is designed to catch.
  10. Re-test after any change to the source data or the lookup table.

SOP 9.2: Decision rule

If the error has a known and valid cause, handle it at the point of the calculation with the narrowest function that catches it. If the cause is unknown, leave the error visible until you have found it. A workbook that shows an honest #N/A is more useful than one that shows a confident blank.

Small Business CEO Dashboard

Get the finished file

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 →

Scroll to Top