ShareYourGroupShareYourGroupExcel Formulas

Logical functions

IFERROR and IFNA functions in Excel

IFERROR returns a value you choose when a formula gives an error, and the formula's own result when it does not.

A sheet full of #N/A and #DIV/0! looks broken even when nothing is wrong: the code simply was not in the list, or the month has no sales yet. IFERROR lets you decide what the reader sees in those cases.

Syntax

=IFERROR(value, value_if_error)
=IFNA(value, value_if_na)
ArgumentWhat it is
valueThe formula or value to check.
value_if_errorWhat to show if the formula gives any error.
value_if_naFor IFNA: what to show if the formula gives the #N/A error only.

Examples

Each result below is what Excel itself showed for the formula on the sample sheet.

Sample sheet: A small price list with item codes. The table is sorted by code.
ABCDE
1CodeItemCategoryPriceStock
2A101Basmati Rice 5 kgGrocery65040
3A102Toor Dal 1 kgGrocery16075
4B201NotebookStationery60300
5B202Ball PenStationery100
6C301LED BulbElectronics110200
7C302Power BankElectronics129918
8D401Steel BottleHome45055

How it works

IFERROR works out the formula in its first argument. If the result is fine, that result is shown. If it is any error value, the second argument is shown instead. The formula is written once, which is the improvement over the older pattern =IF(ISERROR(formula), "message", formula).

The replacement can be anything:

A second lookup as the fallback

=IFERROR(VLOOKUP(A2,ThisYear,2,FALSE), VLOOKUP(A2,LastYear,2,FALSE)) tries one table and, if the code is not there, the other. You can chain three or four tables this way.

IFERROR hides every error, including your mistakes

This is the danger, and the last example shows it. The formula asks for column 9 of a five-column table. That is a typing mistake, and Excel would normally say #REF!. Wrapped in IFERROR, the cell calmly says "Not found", and the mistake may never be noticed.

IFERROR catches all of these:

ErrorUsual meaning
#N/Aa lookup found nothing
#DIV/0!division by zero or by an empty cell
#VALUE!text where a number was needed
#REF!a reference to cells that do not exist
#NAME?a misspelt function or name
#NUM!a number that is impossible or too large

Only the first two are normally "expected". The rest mean the formula itself is wrong.

Prefer IFNA for lookups

IFNA catches #N/A and nothing else. For a lookup that is what you want: a missing code is handled, and a real mistake still shows as an error so that you can fix it. Compare the fourth and fifth examples. IFNA is in Excel 2013 and later.

XLOOKUP has the same protection built in, as its fourth argument.

Good habits

  1. Build the formula without IFERROR first, and make sure it gives right answers.
  2. Add the wrapper last.
  3. Use IFNA for lookups and a plain test for division: =IF(E5=0,0,D2/E5) says exactly which case you are handling.
  4. Think about what the replacement means. A 0 for a missing price will flow into totals as if the item were free. Sometimes a visible "Not found" is the honest answer.

In Google Sheets

Google Sheets has IFERROR and IFNA. There, the second argument of IFERROR is optional and the result is blank if you leave it out.

Related functions

Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.

This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.