You can handle errors in Excel by using the IFERROR function, which returns a specific value (like 0 or a message) if a formula results in an error, or the original formula result if it works correctly. This function replaces the older IF(ISERROR( formula structure and is easier to read and write.
What You'll Need
- A computer with Microsoft Excel installed (Excel 2007 or later is required for IFERROR).
- A spreadsheet file containing a formula that you suspect might produce an error.
- A specific value or message you want to display instead of the error code.
Step-by-Step
- Locate the cell with the error: Click on the cell containing the formula that is generating the error (e.g., #DIV/0!, #N/A, #VALUE!, #REF!, #NAME?, or #NUM!).
- Select the formula cell again: Click on the same cell once more or click inside the formula bar at the top of the window to edit the formula.
- Open the Insert Function dialog (optional but recommended for beginners): Click the "fx" button located to the left of the formula bar. Alternatively, press Shift + F3 on your keyboard.
- Search for IFERROR: In the "Search for a function" box at the top of the dialog, type IFERROR and click "Go". Select "IFERROR" from the list and click "OK".
- Enter the Value_if_error: In the first box labeled Value_if_error, type what you want Excel to display if the formula fails. This could be a number (e.g., 0), a text message (e.g., "Not Available"), or another formula. For example, to hide a #N/A error, you might type 0.
- Enter the Value: In the second box labeled Value, type or select the original formula that you want to evaluate for errors. You can type the formula directly, or click the small arrow to the right of the box to select it from the spreadsheet. Ensure the parentheses are balanced.
- Complete the function: Click "OK" to close the dialog box. The cell will now display your chosen value if the original formula results in an error, or the correct result if it works.
- Drag to apply to other cells: If you have a column of similar calculations, click the bottom-right corner of the cell containing the new IFERROR formula (the small square handle) and drag it down or across to apply the same logic to the rest of the data.
Common Mistakes
- Using IFERROR on the wrong cell: Applying the function to the cell containing the error message itself, rather than the cell containing the original calculation, will not fix the underlying issue and will just hide the error message.
- Not closing the parentheses: In the formula bar, the IFERROR function is
=IFERROR(formula, value). Forgetting to type the closing parenthesis at the very end will result in a #NAME? error in the cell. - Overusing it to hide real problems: If a formula is designed to divide by zero because a data entry is missing, using IFERROR to return 0 might hide a critical data issue that needs to be corrected. Use IFERROR to handle expected errors (like a lookup failing) rather than to ignore calculation errors caused by user input.
- Forgetting to update the reference: When dragging the formula to adjacent cells, ensure that cell references are correct (e.g., using relative references like
A1instead of absolute references like$A$1unless that is your intention).
Tips
- Use descriptive messages: Instead of returning a plain 0 or blank, return a text string like "Data Not Found" or "N/A". This makes your spreadsheet much more user-friendly and easier to interpret.
- Combine with VLOOKUP: A common use case is in VLOOKUP formulas that might not find a match. Wrapping the VLOOKUP in IFERROR helps prevent the dreaded
#N/Afrom cluttering your report. - Check for #N/A specifically: While IFERROR catches all errors, if you only care about #N/A errors (common in lookups), you can use the ISNA function in an IF statement instead:
=IF(ISNA(VLOOKUP(...)), "Not Found", VLOOKUP(...)). This is useful if you want other errors, like #REF!, to still propagate up. - Use for cleaner charts: If you are creating a chart and one of your data points contains an error, the chart will often break or display a gap. Using IFERROR to replace errors with 0 (or a placeholder) ensures your chart renders correctly.
Troubleshooting
If the IFERROR function is not working as expected, check the following common issues:
- The cell shows the error, not the result: Ensure that you are editing the cell containing the original formula, not the cell containing the error message itself. The IFERROR function replaces the error result, it does not fix the formula in the cell below it.
- The syntax is incorrect: If the cell displays
#NAME?, you likely missed a closing parenthesis or misspelled the function name. Check that the formula starts with=IFERROR(and ends with). - The formula inside IFERROR is causing a circular reference: If the formula you are trying to protect is referring back to the cell containing the IFERROR formula, you will get a circular reference warning. You must change the structure of your spreadsheet to avoid this.
- Excel version compatibility: IFERROR was introduced in Excel 2007. If you are trying to use this function in an older version of Excel, it will not work. You must use the older
IF(ISERROR(...))structure instead.
Frequently Asked Questions
What is the difference between IFERROR and IF(ISERROR(x))?
IFERROR is a simplified function introduced in Excel 2007 that combines the logic of checking for an error and then returning a specific value. The older method requires nesting the ISERROR function inside an IF function, which makes the formula longer and harder to read and maintain.
Can I use IFERROR to replace a specific type of error only?
No, IFERROR catches all error types (like #DIV/0!, #N/A, #VALUE!, etc.) and replaces them with your specified value. If you need to handle only one specific type of error, you should use the IF and ISERROR or ISNA functions separately.
Does IFERROR work with array formulas?
Yes, IFERROR can be used with array formulas, but it is important to ensure that the entire array formula is wrapped inside the IFERROR function. If you only wrap part of the array formula, you will likely get an error.
Why does my formula still show an error after using IFERROR?
If the formula still shows an error, it is likely because the formula is referencing the cell containing the IFERROR function itself, creating a circular reference. Check your formula references to ensure they do not point to the cell you are currently editing.
Is IFERROR available in Google Sheets?
Yes, Google Sheets supports the IFERROR function with the same syntax and behavior as Microsoft Excel.