WorksheetFunction.IfError method (Excel)

Returns a value that you specify if a formula evaluates to an error; otherwise, returns the result of the formula. Use the IfError function to trap and handle errors in a formula.

Syntax

expression.IfError (Arg1, Arg2)

expression A variable that represents a WorksheetFunction object.

Parameters

Name Required/Optional Data type Description
Arg1 Required Variant Value - the argument that is checked for an error.
Arg2 Required Variant Value_if_error - the value to return if the formula evaluates to an error. The following error types are evaluated: #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME?, or #NULL!.

Return value

Variant

Remarks

If value or value_if_error is an empty cell, IfError treats it as an empty string value ("").

If value is an array formula, IfError returns an array of results for each cell in the range specified in value.

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.