Logic and errors function
IFERROR function in Google Sheets and Excel
IFERROR returns a value when it's fine and a fallback of your choice when it's any error.
Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet
- Excel 2016
- Excel 2019
- Excel 2021
- Excel 2024
- Microsoft 365
- Google Sheets
Syntax
IFERROR(value, value_if_error)Arguments in [brackets] are optional. Google Sheets writes it IFERROR(value, [value_if_error]).
Example
=IFERROR(C2/B2,0) reads: Divide sales C2 by clicks B2, and show 0 instead of an error when that fails (a campaign with 0 clicks).
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Campaign | Clicks | Sales | Conversion | Owner |
| 2 | Spring email | 1200 | 36 | 3.0% | Mara |
| 3 | 860 | 12 | 1.4% | ||
| 4 | Display ads | 0 | 0 | 0.0% | Jonas |
| 5 | Search ads | 2300 | 69 | 3.0% | Priya |
| 6 | Newsletter | 540 | 27 | 5.0% | |
| 7 | Partner blog | 0 | 0 | 0.0% | Kenji |
D4 shows 0.0% instead of #DIV/0!; rows with clicks still show their conversion, like 3.0% in D2.
How the spreadsheet calculates it
Returns C2 divided by B2, but if that gives any error, shows 0 instead. Careful: it hides every error, typos included.
- 1. IFERROR: Returns
C2divided byB2, but if that gives any error, shows0instead. Careful: it hides every error, typos included.value=`C2/B2`: the calculation that might failfallback=`0`: what to show instead of an error
More IFERROR examples
=IFERROR(C2/B2,0)The conversion rate, or 0 when there were no clicks.=IFERROR(C2/B2,"")The same, but the cell looks empty instead.=IFERROR(VALUE(A2),"Not a number")Convert text to a number, with a message when it can't.
Paste any of these into the formula explainer to see it step by step.
Tips
- Prefer IFNA around lookups so a broken formula still shows its error.
- Prefer testing the cause (
IF(B2=0, "", C2/B2)) when you know what the error will be. - Use "" as the fallback when an empty-looking cell reads better than 0, but remember that "" is text in further maths.
- Add IFERROR last, after the formula works, so it can't hide a mistake you made while writing it.
What IFERROR is used for
Keeping dashboards clean where some rows can't be calculated yet (no clicks, no sales), and giving lookups a friendly fallback when every error really means “not available”.
Arguments
| Argument | Required | What it is |
|---|---|---|
| value | Yes | The calculation that might fail, such as C2/B2 or a lookup. |
| value_if_error | Yes | What to show instead of an error: 0, "" for a blank look, or a message.Watch out: Required in Excel; leaving it out isn't valid. |
Common mistakes
Leaving out the fallback:
IFERROR(C2/B2)isn't complete.Wrapping everything in IFERROR, so real mistakes stay hidden.
Wrapping lookups in IFERROR: it also hides a wrong column number (#REF!). IFNA only catches “not found”.
Hiding an error before knowing why it happens.
In Google Sheets
Google Sheets' IFERROR makes the second argument optional: left out, an error shows as a blank.
Errors you may see with IFERROR
Questions
How do I use IFERROR with VLOOKUP?
Wrap the whole lookup and add the fallback: =IFERROR(VLOOKUP(B2,$G$2:$J$8,4,FALSE),"Not found"). The guide on how to use IFERROR with VLOOKUP shows it on a live sheet, with IFNA and XLOOKUP's built-in fallback.
IFERROR or IFNA?
IFNA around lookups, IFERROR only when every error means the same thing. See IFERROR vs IFNA.
How do I show a blank instead of an error?
Use an empty string as the fallback: IFERROR(C2/B2, "").
Does IFERROR slow a spreadsheet down?
Microsoft's page doesn't say, and we haven't measured it. Choose it for meaning: use it only where hiding every error is what you want.
Sources
Official documentation the facts on this page were checked against.