Making Your Formulas Check for Errors

Written by Allen Wyatt (last updated December 10, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


It is often helpful to check if a cell contains an error condition so that your formula can know how to calculate results that may be dependent on that cell. Excel provides the IFERROR function to help determine this information. The purpose of this function is to help simplify how you check for potential errors in your formulas. Consider a rather simple example:

=B8/B9

In most instances this formula will return a good result—unless cell B9 contains a zero value. In that case, Excel returns a #DIV/0! error. The traditional approach to trap this potentiality is to use the ISERROR function in this manner:

=IF(ISERROR(B8/B9),0,B8/B9)

The ISERROR function returns either True or False, depending on whether the expression being evaluated returns an error or not. The surrounding IF function can then act upon the value returned by ISERROR to determine what should be displayed.

The problem with this approach is that it is rather convoluted. Note, for instance, that your evaluation (B8/B9) needs to be included twice in the full formula. While that may not seem problematic with such a simple evaluation, with longer formulas it can be a real pain—at a minimum it makes your overall formula twice as long as it should be and provides two formulas that need to be kept in sync when you make changes.

This is where the IFERROR function comes into play. It helps simplify the formulas you create. The following is the equivalent of the traditional formula presented earlier:

=IFERROR(B8/B9,0)

In this instance, the formula B8/B9 is evaluated and, if it results in an error, the 0 value is returned. If there is no error, then the value of the formula being evaluated is instead returned.

You can find additional information about the IFERROR function at this web page:

https://exceljet.net/excel-functions/excel-iferror-function

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7800) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Saving All Open Workbooks

Wouldn't it be nice to have a single command that would save each of you open workbooks, all at once? It's easy to do ...

Discover More

Rechecking Spelling and Grammar

If you ever need to check the spelling or grammar of a document from scratch, it can be confusing knowing the proper ...

Discover More

Using a Single-Column Heading in a Multi-Column Layout

Want different numbers of columns all on the same page? Word makes it easy to use, for instance, a heading that uses a ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Summing Digits in a Value

Want to add up all the digits in a given value? It's a bit trickier than it may at first seem.

Discover More

Counting Occurrences of Words

If you would like to determine how many instances of a particular word appear within a range of text, there are several ...

Discover More

Determining the Used Range

You may have a need to determine the range occupied by data within a worksheet. The approach you take in devising a ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.