IFERROR Function in Excel (4 Examples)

Sumit Bansal
Written by
Sumit Bansal
Sumit Bansal

Sumit Bansal

Sumit Bansal is the founder of TrumpExcel.com and a Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

If you have a formula that sometimes returns an error like #N/A or #DIV/0!, and you want to show something friendlier in its place, the IFERROR function is what you need.

It checks your formula, and the moment it hits an error, it swaps in a value you choose.

In Excel 365, you can also hand IFERROR a whole range and it cleans up every error in one spilled formula.

In this article, I’ll show you how to use IFERROR with real examples, from catching division errors to handling failed lookups and adding up a column that contains errors.

IFERROR Syntax

Here is the syntax of the IFERROR function:

=IFERROR(value, value_if_error)
  • value – the formula or expression you want to check for an error. This is usually a calculation or another function like a lookup.
  • value_if_error – what to return when value evaluates to an error. It can be text, a number, a blank (""), or even another formula.

Both arguments are required. If value doesn’t return an error, IFERROR just hands back its normal result.

Pro Tip: IFERROR catches every error type Excel throws: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, and #NULL!. If you only want to catch a failed lookup (#N/A) and still see the rest, use IFNA instead. More on that later in this article.

IFERROR works in Excel for Microsoft 365, Excel 2024, 2021, 2019, 2016, and Excel on the web.

When to Use IFERROR

Use the IFERROR function when you want to:

  • Replace an ugly error value with a clean message or a blank cell in a report.
  • Handle a lookup that comes up empty, so you show “Not found” instead of #N/A.
  • Avoid a #DIV/0! error when a denominator might be zero or blank.
  • Add up a column that has a few error cells in it without the total breaking.

Let me show you a few practical examples of how this works.

Example 1: Catch a Division Error with IFERROR

Let’s start with one of the most common cases: division that sometimes breaks.

Below is a table of ad campaigns, with the campaign name in column A, the number of conversions in column B, and the ad spend in column C. A couple of campaigns had zero conversions.

Excel table with columns for Campaign, Conversions, and Ad Spend, showing empty cells for Cost per Conversion calculation

I want the cost per conversion for each campaign, without a #DIV/0! showing up for the campaigns that had no conversions.

Here is the formula:

=IFERROR(C2:C9/B2:B9,"No conversions")
Excel formula bar showing IFERROR function used to replace division errors with No conversions in column D

Here C2:C9/B2:B9 divides the spend by the conversions for every row at once. When a campaign has zero conversions, that division returns a #DIV/0! error, and IFERROR replaces it with the text “No conversions”.

Because I passed whole ranges, the formula spills a result down the column on its own. You type it once and Excel fills the rest. No dragging.

Pro Tip: The spilling version needs Microsoft 365 or Excel 2021. On older versions, put =IFERROR(C2/B2,”No conversions”) in the first cell and copy it down. If you want to understand what causes it in the first place, here is how to get rid of the #DIV/0! error in Excel.

Example 2: Show a Message When a Lookup Fails

A classic use of IFERROR is cleaning up a lookup that doesn’t find a match.

Below I have an employee list, with the employee ID in column A and the department in column B. In cell E2 I can type an ID to look up.

Excel table with Employee ID and Department data, plus a Lookup ID field for E-115 to demonstrate IFERROR handling

I want to type an employee ID in E2 and get their department back, but show a clear message when the ID isn’t in the list.

Here is the formula:

=IFERROR(XLOOKUP(E2,A2:A11,B2:B11),"ID not found")
Excel formula bar showing IFERROR with XLOOKUP returning ID not found for a missing employee ID in cell F2

The XLOOKUP function looks for the ID from E2 in column A and returns the matching department from column B. When the ID isn’t there, XLOOKUP returns #N/A, and IFERROR turns that into “ID not found”.

Pro Tip: XLOOKUP (available in Excel 365 and 2021) has its own if_not_found argument, so you can write =XLOOKUP(E2,A2:A11,B2:B11,”ID not found”) and skip IFERROR here. IFERROR is still the go-to for VLOOKUP, which has no such option. Here is how to wrap VLOOKUP in IFERROR to get rid of #N/A errors.

Example 3: Flag Text Where a Word Isn’t Found

IFERROR is also handy with functions that error when they don’t find something, like SEARCH.

Below I have a list of customer comments in column A. I want to check which ones mention the word “refund”.

Excel table showing Customer Comment in column A and empty Refund Mention column B for IFERROR function example data

I want the position where “refund” appears in each comment, and the text “Not mentioned” when the word isn’t in that comment.

Here is the formula:

=IFERROR(SEARCH("refund",A2:A9),"Not mentioned")
Excel formula bar showing IFERROR and SEARCH functions to flag missing text in a customer comment spreadsheet column

SEARCH returns the position where “refund” starts in the comment. When the word isn’t there, SEARCH returns a #VALUE! error, and IFERROR swaps in “Not mentioned” instead.

This spills down the whole column from a single formula. SEARCH also ignores case, so it finds “Refund” and “refund” alike.

Pro Tip: A #VALUE! error can pop up for a few different reasons. If you keep running into one, here is how to fix the #VALUE! error in Excel.

Example 4: Sum a Column That Contains Errors

Here’s one that saves a lot of headaches. If a column has even one error cell, a plain SUM returns an error too. IFERROR lets you add up the good values and ignore the bad ones.

Below I have a payout table, with the region in column A and the payout in column B. A few payout cells still show #N/A from a lookup that didn’t find a match.

Excel table showing Region and Payout columns with #N/A errors in rows 3 and 6, ready for IFERROR function application

I want the total payout across all regions, even though some cells contain #N/A and a normal SUM would just return #N/A as well.

Here is the formula:

=SUM(IFERROR(B2:B9,0))
Excel formula bar showing =SUM(IFERROR(B2:B9, 0)) to sum a column of payouts containing #N/A errors as zero

IFERROR runs across the whole range B2:B9 and turns every #N/A into a 0. SUM then adds up the cleaned-up array, so the errors count as nothing and you get a real total.

In Microsoft 365 and Excel 2021 you just press Enter. There is no need for the old array-formula key combo here.

Pro Tip: On Excel 2019 or earlier, enter this one with Ctrl + Shift + Enter so it works as an array formula. In 365 and 2021, a plain Enter is all you need.

IFERROR vs IFNA: Which Should You Use?

Since these two look similar, it’s worth knowing when to reach for each.

IFERROR catches all seven error types. That’s convenient, but it can hide a real problem. If your own formula has a bug, like a #REF! from a deleted column, IFERROR quietly shows your fallback text and you never spot the mistake.

IFNA catches only #N/A. So a genuine lookup miss gets handled, while other errors still show through for you to fix.

Here is the same lookup from Example 2, written with the employee ID in column A and the department in column B, this time with IFNA.

Excel table showing employee IDs and departments with a lookup field for E-115 to demonstrate IFERROR and IFNA handling

I want the same “ID not found” message for a missing ID, but I still want to see any other error if the formula itself breaks.

Here is the formula:

=IFNA(XLOOKUP(E2,A2:A11,B2:B11),"ID not found")
Excel formula bar showing IFNA and XLOOKUP to return ID not found for a missing lookup value in cell F2

This behaves just like the IFERROR version for a missing ID. The difference shows up only when something else goes wrong, since IFNA leaves those other errors visible.

As a rule of thumb, use IFNA for lookups where you only expect a not-found situation, and use IFERROR when you genuinely want to swallow any error.

Tips & Common Mistakes

A few things to keep in mind when you use IFERROR:

  • It hides every error, including your bugs. IFERROR masks #REF!, #NAME?, and the rest along with the one you meant to catch. Wrap the smallest piece that can fail, not the whole formula, so a real mistake still surfaces.
  • A blank result is text, not truly empty. Using "" as the fallback makes a cell look blank, but it holds an empty string. Functions like COUNTBLANK won’t count it, so keep that in mind for later calculations.
  • value_if_error can be another formula. You can point it at a second lookup, so if the first source fails, IFERROR tries the next one. That’s how people chain fallback sources into one formula.
  • Don’t use it to paper over a fixable error. If a #REF! means a column got deleted, fix the reference instead of hiding it. IFERROR is for expected errors, not broken formulas.
  • It’s been around a long time. IFERROR was added in Excel 2007. Before that people combined the IF function with ISERROR, which you don’t need anymore.

Wrapping Up

IFERROR is one of those small functions that makes your spreadsheets a lot cleaner. Catch a division error, handle a lookup that comes up empty, or add up a column with a few bad cells, and the messy error values disappear.

Just remember to wrap only the part that can fail, so a real mistake still gets your attention. I hope you found this tutorial helpful.

List of All Excel Functions

Other Excel Articles You May Also Like:

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

Free Excel Tips eBook by Sumit Bansal

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free Excel Tips eBook by Sumit Bansal

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free-Excel-Tips-EBook-Sumit-Bansal-1.png

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster

Free Excel Tips EBook Sumit Bansal

FREE EXCEL E-BOOK

Get 51 Excel Tips Ebook to skyrocket your productivity and get work done faster