Safe division
| A | B | |
|---|---|---|
| 1 | Revenue | Units |
| 2 | 10 | 0 |
Formula: D2: =IFERROR(A2/B2,0)
Result: 0
Dividing by zero gives #DIV/0!, which IFERROR replaces with 0.
In Google Sheets the second argument of IFERROR is optional, and leaving it out returns a blank instead of an error.
Excel requires both arguments, so a one-argument IFERROR written in Sheets will not carry over unchanged.
The arguments and common errors are covered in the IFERROR Excel guide; check the function help in Google Sheets for its own argument list.
| A | B | |
|---|---|---|
| 1 | Revenue | Units |
| 2 | 10 | 0 |
Formula: D2: =IFERROR(A2/B2,0)
Result: 0
Dividing by zero gives #DIV/0!, which IFERROR replaces with 0.
| A | B | |
|---|---|---|
| 1 | SKU | Price |
| 2 | A101 | 24.99 |
| 3 | A102 | 39 |
Formula: D2: =IFERROR(VLOOKUP("Z9",A2:B3,2,FALSE),"Not found")
Result: Not found
Z9 is not in the list, so VLOOKUP returns #N/A and IFERROR shows the text.
| A | |
|---|---|
| 1 | Notes |
| 2 | n/a |
| 3 | pending |
Formula: D1: =IFERROR(AVERAGE(B2:B4),"No data")
Result: No data
AVERAGE of cells with no numbers gives #DIV/0!, replaced by "No data".
A tiny spreadsheet with example data. Edit the formula or any number and see the result.
Formula in F2: =IFERROR(B3/D3,"n/a")
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Student | Score | Extra credit | Attempts | Result | |
| 2 | Ann | 92 | Yes | 2 | n/a | |
| 3 | Bob | 74 | No | 0 | ||
| 4 | Cy | 58 | Yes | 3 | ||
| 5 | Dee | 81 | No | 1 | ||
| 6 | Eli | 66 | 2 |
Google Sheets is used here only as a descriptive product name. FormulaCamp is not affiliated with Google.
Enter — commit · F2 — edit · F4 — $ in a reference · Ctrl+C/Ctrl+V — copy and paste · Ctrl+Z — undo
Esc or F6 — leave the sheet for the «Check» button · Shift+Tab in the first cell — back to the page