How to Write a Nested IFERROR Statement in Excel
To write a nested IFERROR statement in Excel, you need to use the IFERROR function multiple times within one formula. The IFERROR function checks if a given expression returns an error, and if it does, it returns a specified value instead of the error. The syntax for the IFERROR function is:
=IFERROR(value, value_if_error)Where:
valueis the expression or formula you want to test for an error.value_if_erroris the value to return if the expression results in an error.
Here's how to create a nested IFERROR statement in Excel:
- Start by writing the first IFERROR function. This will include the main expression or formula you want to check for errors.
- For the
value_if_errorargument, add another IFERROR function. This second IFERROR function will check for errors in a different expression or formula. - Repeat this process for as many nested levels as needed, always using the
value_if_errorargument to include the next IFERROR function. - Finally, specify the value to return if all expressions result in errors.
Example
Let's say we have a table with the following data:
| A | B | C |
|---|---|---|
| 10 | 20 | 30 |
| 0 | 40 | 50 |
| 20 | 0 | 60 |
We want to calculate the division of the values in columns A, B, and C (A/B/C), but we want to avoid errors due to division by zero. We can use a nested IFERROR statement to achieve this.
- Start by writing the first IFERROR function:
=IFERROR(A1/B1, "Error"). This will return the result of A1 divided by B1 or "Error" if B1 is 0. - For the
value_if_errorargument of the first IFERROR function, add another IFERROR function:=IFERROR((A1/B1)/C1, "Error"). This will return the result of (A1/B1) divided by C1 or "Error" if C1 is 0. - Now, we have a nested IFERROR statement:
=IFERROR(A1/B1, IFERROR((A1/B1)/C1, "Error")).
The final formula looks like this:
=IFERROR(A1/B1, IFERROR((A1/B1)/C1, "Error"))With this formula, Excel will check for errors in the divisions of A1/B1 and (A1/B1)/C1, and return the appropriate result or "Error" if an error occurs.