The Excel IFERROR function returns a custom result when a formula generates an error, and a standard result when no error is detected. IFERROR is an elegant way to trap and manage errors without using more complicated nested IF statements.
- value – The value, reference, or formula to check for an error.
- value_if_error – The value to return if an error is found.
Use the IFERROR function to trap and handle errors produced by other formulas or functions. IFERROR checks for the following errors: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!.
For example, if A5 contains 10, B5 is blank, and C5 contains the formula =A5/B5, the following formula will trap the #DIV/0! error that results from dividing A5 by B5:
=IFERROR (A5/B5. “Please enter a value in B5”)
In this case, C5 will display the message “Please enter a value in B5” if B5 is blank or zero.
- If value is empty, it is evaluated as an empty string (“”) and not an error.
- If value_if_error is supplied as an empty string (“”), no message is displayed when an error is detected.
- If IFERROR is entered as an array formula, it returns an array of results with one item for each cell in value.