ID EN
#Logical

IFERROR

Excel Functions

Trap and handle errors

Syntax

EXCEL
=IFERROR(value, value_if_error)

Arguments

Parameter Description
value The value, reference, or formula to check for an error.
value_if_error The value to return if an error is found.

Return Value

The value you specify for error conditions.

Details

The IFERROR function returns a custom result when a formula returns an error and a normal result when a formula calculates without an error. The typical syntax for the IFERROR function looks like this: In the example above, "formula" represents a formula that might return an error, and "custom" represents the value that should be returned if the formula returns an error. This makes IFERROR an elegant way to trap and manage errors in one step. Before the introduction of IFERROR, it was necessary to use more complicated nested IF statements together with the older ISERROR function. You can 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!. In the example

Examples

Example 1

The IFERROR function returns a custom result when a formula returns an error and a normal result when a formula calculates without an error. The typic

EXCEL
=IFERROR(formula,custom)
Example 1 - Trap #DIV/0! errors

In the example shown, the formula in E5 copied down is:

EXCEL
=IFERROR(C5/D5,0)
Example 1 - Trap #DIV/0! errors

This formula catches the #DIV/0! error that occurs when the quantity field is empty or zero, and replaces it with zero. You are free to change the zer

EXCEL
=IFERROR(C5/D5,"")
Example 2 - request input before calculating

Sometimes you may want to suppress a calculation until the worksheet receives specific input. For example, if A1 contains 10, B1 is blank, and C1 cont

EXCEL
=IFERROR(A1/B1) // returns #DIV! if B1 is empty
Example 2 - request input before calculating

The formula below has been modified to use the IFERROR function to trap the #DIV/0! error and remap it to the message "Please enter a value in B1".

EXCEL
=IFERROR(A1/B1,"Please enter a value in B1")
Example 3 - Sum and ignore errors

A common problem in Excel is that errors in data will corrupt the results of other formulas. For example, in the worksheet shown below, the goal is to

EXCEL
=SUM(D5:D15) // returns #N/A

See Also

ISERROR IFNA