Excel functions · Logic
IFERROR function in Excel
IFERROR returns the result of a formula, or a value you choose if that formula returns an error, such as 0 instead of #DIV/0! or "Not found" instead of #N/A. It catches every error type, so use it where you expect an error, not to hide mistakes.
Last reviewed
Syntax
=IFERROR(value, value_if_error)- valuerequired
- The formula or value to check for an error.
- value_if_errorrequired
- What to return if value is an error such as #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? or #NULL!.
- IFNA catches only #N/A, which is safer for lookups: a broken reference still shows up.
- IFERROR hides typos too. Build the formula first, then wrap it.
Which versions have IFERROR
Every current Excel version: Microsoft 365, Excel for the web, Excel 2024, 2021, 2019 and 2016, on Windows and Mac.
| Version | Has it |
|---|---|
| Microsoft 365 (Windows and Mac) | Yes |
| Excel for the web | Yes |
| Excel 2024 | Yes |
| Excel 2021 | Yes |
| Excel 2019 | Yes |
| Excel 2016 | Yes |
Google Sheets
Google Sheets has IFERROR. Its second argument is optional: leave it out and an error becomes a blank cell.
Examples
The examples use this sample sheet.
| Row | A | B | C |
|---|---|---|---|
| 1 | Rep | Revenue | Units |
| 2 | Ana | 4800 | 40 |
| 3 | Ben | 0 | 0 |
| 4 | Cara | 3150 | 35 |
1.A division that works
=IFERROR(B2/C2, 0)Result: 120
4,800 / 40 has no error, so IFERROR returns it unchanged.
2.Catch #DIV/0!
=IFERROR(B3/C3, 0)Result: 0
Ben has 0 units, so B3/C3 would be #DIV/0!. IFERROR returns 0 instead.
3.Catch a failed lookup
=IFERROR(VLOOKUP("Dev", A2:C4, 2, FALSE), "Not found")Result: Not found
There's no Dev in the table, so VLOOKUP's #N/A becomes a message.
Common errors and fixes
| Error | Why it happens | Fix |
|---|---|---|
| Hidden mistakes | IFERROR masks every error, including a #REF! from a deleted column or a #NAME? from a typo. | Use IFNA for lookups, and check the unwrapped formula first. |
Do it with GPTExcel
Skip writing IFERROR by hand
Upload your Excel or CSV file to Chat and ask in plain English. GPTExcel writes the formula for your file and your version of Excel or Google Sheets.
Calculate revenue per unit for each rep and show 0 where units are 0.
Done. I used IFERROR on your sheet and checked the results against your data.
- Written for your platform and version
- Checked against your actual data
- Newest functions looked up in official docs
IFERROR questions
- What's the difference between IFERROR and IFNA?
- IFERROR catches every error type. IFNA catches only #N/A, the error lookups return when nothing matches, so real problems like #REF! still show.
- Can IFERROR return a blank?
- Yes: =IFERROR(B3/C3, "") shows an empty-looking cell instead of the error.
Skip the formula hunt
Upload a spreadsheet and ask in plain English. Free plan, no credit card.
Start free