To use IFERROR with IF in Excel, put the IF function inside IFERROR: =IFERROR(IF(B2=0,"No quantity",A2/B2),"Check values"). IF makes the decision, while IFERROR supplies a fallback only if the calculation produces an Excel error.
What IFERROR with IF means
IF and IFERROR solve related but different problems. IF tests a condition and returns one result when it is true and another when it is false. IFERROR checks whether a calculation returns an error; if it does, Excel shows the fallback you specify instead. Combining them lets a formula make a normal decision and also handle unexpected errors.
For example, a worksheet might calculate a price per item only when a quantity is available. IF can decide what to show when the quantity is zero. IFERROR can catch a separate problem, such as text accidentally entered in a cell that should contain a number. The two functions are not interchangeable: IF does not automatically catch errors, and IFERROR does not test business rules such as whether a value is above a target.
In the opening example, the IF test handles a zero quantity with the ordinary text result “No quantity.” If the remaining division fails for another reason, IFERROR returns “Check values.” This distinction is useful: a zero denominator is an expected situation, while an invalid input may need investigation.
How Excel evaluates the nested functions
Excel evaluates the inner IF first. It checks the logical test, then returns the selected true or false result. IFERROR evaluates the result of that inner expression. If the result is a regular value—such as a number, blank string, or text label—IFERROR leaves it alone. If the result is an Excel error, IFERROR replaces it with the fallback value.
The general structure is therefore “IFERROR around IF.” In the IF portion, provide a condition and the two outcomes. In the outer IFERROR portion, provide the full IF expression as the value to check, followed by the result to show if that expression errors. The fallback can be text, a number, a blank string, or another formula.
Crucially, IFERROR does not replace every result that looks undesirable. If IF returns “Review,” that is text, not an Excel error, so IFERROR will leave it unchanged. Likewise, a formula returning zero is not an error. Use IF to define expected outcomes; reserve IFERROR for genuine calculation errors.
Syntax and a basic example
Assume A2 contains total revenue and B2 contains units sold. The formula below returns revenue per unit when B2 is nonzero, gives a clear message when there are no units, and catches other errors:
=IFERROR(IF(B2=0,"No quantity",A2/B2),"Check values")
With A2 equal to 120 and B2 equal to 4, the result is 30. With B2 equal to 0, the result is “No quantity,” not an error message, because the IF test handles zero before division occurs. If A2 contains the text “pending” while B2 is 4, the division produces an error and the result is “Check values.”
When entering the formula, select the result cell, type the expression, and press Enter. In Excel for Microsoft 365 on Windows, formulas normally use commas between arguments. Some regional settings use a different list separator, so Excel may require semicolons instead; follow the separator your installation accepts. On Mac, the formula logic is the same, though regional settings can also affect separators.
Practical examples for common worksheets
-
Classifying a score: Assume C2 contains a test score. This formula distinguishes a numeric score from a missing or nonnumeric entry, then labels a valid score:
=IFERROR(IF(ISNUMBER(C2),IF(C2>=70,"Pass","Review"),"Enter numeric score"),"Check source")If C2 contains 82, the result is “Pass.” If it is blank or contains ordinary text, the result is “Enter numeric score.” If the cell itself contains an error, the outer IFERROR returns “Check source.”
-
Returning a blank for an intentionally empty row: Assume A2 is an amount and B2 is a divisor. This formula avoids displaying a warning when the amount cell is blank, but still handles division errors for a populated amount:
=IF(A2="","",IFERROR(A2/B2,"Check values"))If A2 is blank, the result is blank. If A2 is 120 and B2 is 0, the result is “Check values.” If A2 is 120 and B2 is 4, the result is 30. This is an example of IFERROR nested inside IF rather than the other way around.
-
Applying a threshold while protecting a calculation: Assume D2 contains units and E2 contains the sales target. This formula checks whether units meet the target and catches errors in either referenced calculation:
=IFERROR(IF(D2>=E2,"Met","Below target"),"Review inputs")If D2 is 12 and E2 is 10, Excel returns “Met.” If either cell contains an error, the comparison also errors and the formula returns “Review inputs.”
These examples show why the IF test should represent the actual rule in the worksheet. Use readable messages that explain what happened, rather than using one generic fallback for every situation.
Choosing where to put IFERROR
Putting IF inside IFERROR is usually the clearest choice when the entire decision should have one error fallback. It makes the formula read as: “perform this decision, and if that expression errors, show this alternative.” The revenue-per-unit example follows this pattern.
Putting IFERROR inside IF is useful when the condition should be checked before a risky calculation. In the blank-row example, an empty A2 deliberately produces a blank result, so the formula checks that condition first. Only the other branch attempts the division and needs error handling.
You can also use several IF functions within one IFERROR when there are multiple outcomes. Keep the tests in a sensible order, because Excel returns the result for the first true test it reaches. If a formula becomes difficult to read, use intermediate columns with meaningful headings or split the logic into smaller steps. That can make it easier to find which condition or calculation is responsible for an unexpected answer.
Common problems and misconceptions
-
Expecting IFERROR to fix a wrong result: It only responds to Excel errors. A formula can return a plausible but incorrect number without triggering IFERROR. Check the condition, references, and arithmetic when the result is wrong but no error appears.
-
Hiding useful error information: A fallback such as “Check values” is friendlier than a raw error, but it can conceal whether the cause was #DIV/0!, #VALUE!, or another issue. During development, inspect the underlying formula or temporarily remove IFERROR to identify the actual error.
-
Confusing a blank with zero: A formula that returns an empty string, written as two quotation marks with nothing between them, displays a blank-looking result. It is not the same as a truly empty cell and may behave differently in later calculations, filters, or charts.
-
Using text for every fallback: Returning “Not available” is readable, but it can interfere with later arithmetic because text is not a numeric value. If the result will feed another calculation, consider whether a blank or a meaningful numeric value is appropriate instead.
-
Adding IFERROR when IF already handles the case: If an IF test reliably prevents a division by zero, the calculation may not need an outer error handler. Keep IFERROR when other plausible errors remain, not merely as decoration around every formula.
When to use IFNA or another approach
IFERROR catches a broad range of Excel errors, including #DIV/0!, #VALUE!, #REF!, #NAME?, and #N/A. Newer Excel features can also produce errors such as #SPILL! or #CALC!. This broad coverage is convenient, but it can hide problems unrelated to the condition you meant to handle.
If the only expected issue is a lookup value that is not found, IFNA is a narrower option: it replaces #N/A but lets other error types remain visible. That can help preserve clues about broken references or invalid calculations. If the issue is an ordinary input condition—such as an empty cell or a zero quantity—an IF test is often more precise than catching an error after it occurs.
Another useful approach is to validate inputs directly. ISNUMBER can test whether a cell contains a number, and a blank check can decide what to do with missing data. These checks can produce clearer messages and make the worksheet’s rules explicit. They do not remove the need for error handling in every case, but they can prevent expected problems from arising in the first place.
Compatibility and formula behavior
IF and IFERROR are available in current Microsoft Excel, including Excel for Microsoft 365 on Windows and Mac. IFERROR was introduced in Excel 2007, so it is also present in later desktop releases. The formulas in this article use standard functions and do not require a newer dynamic-array function.
In Excel for the web, the same basic formulas work, although the interface for entering and editing formulas differs from the desktop application. Excel may also adjust references when a formula is copied down a column. Relative references such as A2 and B2 normally change to A3 and B3 in the next row; use dollar signs to lock a reference when a formula should continue pointing to a fixed cell.
For formulas that return arrays, Excel for Microsoft 365 can apply error handling to the resulting calculation as well. If you are working with a large array formula, check the displayed output and the underlying inputs before wrapping the whole expression in IFERROR, because a broad fallback may make it harder to spot an error affecting part of the result.
Frequently Asked Questions
Can I use IFERROR inside an IF function?
Yes. Use IFERROR inside IF when the condition should be checked first and only one branch needs error handling. For example, you can return a blank for an empty input and use IFERROR around a division in the other branch.
Does IFERROR catch errors from the IF condition?
Yes, when IF is inside IFERROR. If the condition itself evaluates to an Excel error, the whole inner IF expression errors and the outer IFERROR returns its fallback.
Why does IFERROR not replace “No quantity” with my fallback?
“No quantity” is ordinary text, not an Excel error. IFERROR leaves it unchanged. This is expected when the IF test handles the zero quantity directly.
Should I use IFERROR or IFNA for a lookup?
Use IFNA when you only want to handle a missing-match #N/A result. Use IFERROR if you intend to replace other errors too, but remember that it can hide issues such as invalid references or values.
Can IFERROR return a blank instead of a message?
Yes. Use an empty text value as the fallback. The result will look blank, but it is technically a formula result rather than an empty cell, which can matter to later formulas and data analysis.
Related
- Excel Zoom Shortcut: How to Zoom In, Out, and Set Scale
- Excel Unhide Shortcut: Show Hidden Rows, Columns & Sheets
- Excel Shortcut to AutoFit Column Width on Windows and Mac
Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.
More in Formulas & functions
- Extract Text in an Excel Cell: Formulas and Steps That WorkTo extract part of a cell’s text, use a formula such as TEXTBEFORE for text before a separator,…
- Calculate Age in Months in Excel: Formulas and TipsTo calculate completed age in months in Excel, put a birth date in A2 and enter =DATEDIF(A2,TODAY(),"m") in…
- Outlook Rules: Filter Your Incoming Mail AutomaticallyCreate an Outlook rule by choosing a condition, such as who sent a message or a word in…
- Excel Compare Two Sheets for Matching Names: FormulasTo compare names in two worksheets, enter a formula beside the names on the first sheet and check…
- Excel Concatenate Formula Examples for Text and CellsWith a first name in A2 and a last name in B2, join them with a space using…
- Excel ISBLANK Formula Examples and Common MistakesExcel’s ISBLANK formula checks whether a cell is truly empty: enter =ISBLANK(A2) to get TRUE if A2 has…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.