IFERROR() – Returns a value if an expression errors, otherwise returns the expression's result

The IFERROR() function checks if its first argument (a value or expression) results in an error. If an error occurs, the function returns a specified replacement value. If no error occurs, it returns the result of the original expression.

Syntax

IFERROR(value, replacement)

  • value: The argument to check for an error. This can be a cell reference, a formula, or an expression (e.g., T1A1/T1B1).
  • replacement: The value to return if the value argument evaluates to an error. This can be text, a number, a blank string (""), or another formula.

Basic example

IFERROR(T1A1/T1B1, "Error in calculation")

This example attempts to divide the value in cell T1A1 by the value in cell T1B1.

  • If T1B1 contains 0 (which would cause a division by zero error), the function returns "Error in calculation".
  • If T1A1 = 10 and T1B1 = 2, the division 10/2 results in 5 (no error), so the function returns 5.

Key features

  • Error trapping: Provides a way to gracefully handle errors that might otherwise stop calculations or display unhelpful error messages.
  • Custom error messages: Allows you to display user-friendly messages or alternative values instead of standard error codes.
  • Fallback values/calculations: The replacement can be a static value or another calculation to perform if the primary one fails (e.g., IFERROR(T1A1/T1B1, 0) to return 0 on error).

Practical uses

  • Preventing division by zero errors in calculations: IFERROR(SUM(T1A1:T1A5)/COUNT(T1A1:T1A5), "Cannot calculate average").
  • Displaying "N/A" or "Invalid input" if a formula relies on user input that could be problematic.
  • Substituting a default value, like 0, when an error occurs in a calculation: IFERROR(T1A1/T1B1, 0).

Common mistakes

  • Text replacement not in quotes: If the replacement value is text, it must be enclosed in double quotes.
  • Masking all errors: While useful, IFERROR() can sometimes hide underlying problems in your data or formulas if used too broadly without understanding the cause of potential errors.
  • Incorrect argument order: Ensure the value/expression to check is first, followed by the replacement value.

Report issue

Features, Pricing, Documentation, Support, Login

MathGrid ©

Features,
Pricing,
Documentation,
Support,
Login

MathGrid ©

Back to top Arrow