Search code examples
excelif-statementexcel-formulaerror-checking

IfError with else, does this function exist in Excel?


While trying to help the author of this other question, I bumped (again) into the situation that I would like the following Excel function:

=IFERROR(value, value_if_error, value_if_no_error)

In other words, I'm looking for an IFERROR() function with an else-clause.
The issue is: it can in theory be done as follows:

=IF(IFERROR(function(),error_value),value_if_error,value_if_no_error)

But what if error_value is a possible outcome of function()? That would make it impossible to use IFERROR(): e.g. function() returns a string, which can be anything, also an empty string, but it might also generate an error.

Edit: some clarification

Let me give an example:

=IFERROR(B3, "weird")

In "B3", there is a function, which returns a string, but even in case the value of this string is "weird", this is ok. How can I distinguish the erroneous case and the case where "weird" is a normal correct result?

As an image says more than a thousand words:

enter image description here


Solution

  • Next to IFERROR(), there also is the ISERROR() function, which can be used as an input for an IF()-clause:

    =IF(ISERROR(value),value_if_error,value_if_no_error)