Google Sheets function · Logical
IFERROR in Google Sheets: syntax and examples
IFERROR evaluates a value and, if the result is an error, returns the second argument or a blank cell. It is the usual cover for #N/A from lookups and #DIV/0! from divisions.
Syntax
IFERROR(value, [value_if_error])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
value | any | yes | The expression to evaluate. If it returns an error, the second argument is used. |
value_if_error | any | no | What to return on an error. If left out, the cell stays blank. |
Examples
The examples use this table, starting in A1:
| Item | Revenue | Units | Code |
| Lamp | 800 | 10 | A1 |
| Chair | 549 | 0 | A2 |
| Stand | 129 | 3 | B1 |
| Tray | 340 | n/a | B2 |
=IFERROR(B2/C2, 0)Result: 80
No error, so the division result passes through unchanged.
Run in a Google Sheet (English US locale) on .
=IFERROR(B3/C3, "no units")Result: no units
Division by zero is replaced with a readable message.
Run in a Google Sheet (English US locale) on .
=IFERROR(B4/C4)Result: 43
The second argument is optional. Here nothing fails, so the division result passes through.
Run in a Google Sheet (English US locale) on .
=IFERROR(VLOOKUP("Z", A2:D5, 2, FALSE), "missing")Result: missing
The classic pair: a lookup that finds nothing returns your text, not #N/A.
Run in a Google Sheet (English US locale) on .
=ARRAYFORMULA(IFERROR(B2:B5/C2:C5, "-"))Result:
| 80 |
| - |
| 43 |
| - |
Over a whole column: bad rows show a dash, good rows keep their value.
Run in a Google Sheet (English US locale) on .
Common errors
- It catches every error type, including #NAME? from a misspelled function. A typo can hide behind your fallback text.
- An empty string is not an error, so IFERROR leaves it as it is.
- With one argument, errors turn into a blank cell. Later formulas that read that cell may behave differently from a zero.
- To catch only #N/A, use IFNA. Other errors then stay visible.
Compared with Excel
Same syntax and behavior as Excel IFERROR. In Excel the second argument is required, in Google Sheets it is optional.
Questions and answers
Should I wrap every formula in IFERROR?
No. Wrap only formulas where an error is an expected case, such as a lookup that can miss. Elsewhere the error is a useful signal.