Menu
×
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS

Excel Tutorial

Excel HOME Excel Introduction Excel Get Started Excel Overview Excel Syntax Excel Ranges Excel Fill Excel Move Cells Excel Add Cells Excel Delete Cells Excel Undo Redo Excel Formulas Excel Relative Reference Excel Absolute Reference Excel Arithmetic Operators Excel Parentheses Excel Functions

Excel Formatting

Excel Formatting Excel Format Painter Excel Format Colors Excel Format Fonts Excel Format Borders Excel Format Numbers Excel Format Grids Excel Format Settings

Excel Data Analysis

Excel Sort Excel Filter Excel Tables Excel Conditional Format Excel Highlight Cell Rules Excel Top Bottom Rules Excel Data Bars Excel Color Scales Excel Icon Sets Excel Manage Rules (CF) Excel Charts

Excel PivotTables

Excel PivotTable Intro Excel Create PivotTable Excel PivotTable Values Excel PivotTable Filter Excel PivotTable Group Excel Calculated Field Excel PivotChart

Excel Case

Case: Poke Mart Case: Poke Mart, Styling

Excel Functions

AND AVERAGE AVERAGEIF AVERAGEIFS CONCAT COUNT COUNTA COUNTBLANK COUNTIF COUNTIFS DATEDIF FILTER HLOOKUP IF IFERROR IFS INDEX INDEX MATCH LEFT LEN LOWER MATCH MAX MEDIAN MID MIN MODE NETWORKDAYS NPV OR PROPER RAND RIGHT ROUND SORT STDEV.P STDEV.S SUBSTITUTE SUM SUMIF SUMIFS SUMPRODUCT TEXTJOIN TODAY TRIM UNIQUE UPPER VLOOKUP XLOOKUP XOR

Excel How To

Convert Time to Seconds Difference Between Times NPV (Net Present Value) Remove Duplicates

Excel Cert

Excel Certificate

Excel Examples

Excel Exercises Excel Syllabus Excel Study Plan Excel Training

Excel References

Excel Keyboard Shortcuts


Excel IFERROR Function


Share

IFERROR Function

The IFERROR function is a premade function in Excel, which returns a value of your choice if a formula gives an error.

If the formula does not give an error, IFERROR returns the normal result of the formula.

It is typed =IFERROR and has the following parts:

=IFERROR(value, value_if_error)

Note: The different parts of the function are separated by a symbol, like comma , or semicolon ;

The symbol depends on your Language Settings.

Value: The formula to check for an error, for example a VLOOKUP or a division.

Value_if_error: What to return if the formula gives an error. It can be text in double quotes, a number, or an empty text "", which makes the cell look empty.

IFERROR catches all of these errors:

ErrorCommon cause
#N/AA lookup function did not find the value
#DIV/0!A number is divided by zero or by an empty cell
#VALUE!The formula uses the wrong type of value, like text in a calculation
#REF!The formula refers to a cell or column that does not exist
#NAME?Excel does not recognize a name in the formula, like a misspelled function
#NUM!A number is not valid for the calculation
#NULL!Two ranges that do not meet are separated by a space

How to use the IFERROR function:

  1. Select a cell (H4)
  2. Type =IFERROR
  3. Double click the IFERROR command
  4. Type the formula that can give an error (VLOOKUP(H3, B2:E21, 4, FALSE))
  5. Type (,)
  6. Type the value to show if there is an error ("Not found")
  7. Hit enter

Let's have a look at an example!

This is the same Pokemon table as on the XLOOKUP page. Copy it and paste it into cell A1 to follow along:

Example data

ABCDE
1ID#NameType 1Type 2Total
21BulbasaurGrassPoison318
32IvysaurGrassPoison405
43VenusaurGrassPoison525
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413

Type the labels Search Name in G3 and Total in G4.

Use VLOOKUP to find the Total of a Pokemon based on its Name, and IFERROR to show Not found if the name is not in the table. Type Pikachu in H3:

ABCDEFGH
1ID#NameType 1Type 2Total
21BulbasaurGrassPoison318
32IvysaurGrassPoison405Search NamePikachu
43VenusaurGrassPoison525TotalNot found
54CharmanderFire309
65CharmeleonFire405
76CharizardFireFlying534
87SquirtleWater314
98WartortleWater405
109BlastoiseWater530
1110CaterpieBug195
1211MetapodBug205
1312ButterfreeBugFlying395
1413WeedleBugPoison195
1514KakunaBugPoison205
1615BeedrillBugPoison395
1716PidgeyNormalFlying251
1817PidgeottoNormalFlying349
1918PidgeotNormalFlying479
2019RattataNormal253
2120RaticateNormal413
=IFERROR(VLOOKUP(H3, B2:E21, 4, FALSE), "Not found")

VLOOKUP searches the names in B2:B21 and returns the value from column 4 of B2:E21, which is Total. FALSE means exact match.

Pikachu is not in the table, so VLOOKUP gives an error. IFERROR catches the error and returns Not found instead.

Without IFERROR, the result is #N/A:

GH
3Search NamePikachu
4Total#N/A
=VLOOKUP(H3, B2:E21, 4, FALSE)

Now type Squirtle in H3. Squirtle is in the table, so there is no error, and IFERROR returns the result of VLOOKUP:

GH
3Search NameSquirtle
4Total314

Note: Text in a formula must be inside double quotes: " "



IFERROR with Division

Dividing by zero gives the #DIV/0! error. This often happens when a cell is 0 or empty.

This table shows how many battles some trainers have had, and how many they won. Copy it and paste it into cell A1 of a new sheet:

Example data

ABC
1TrainerBattlesWins
2Ash2013
3Misty86
4Brock104
5Dawn1610
6Gary00

Type Win Rate in D1. The win rate is the wins divided by the battles. Type this formula in D2 and fill it down to D6:

ABCD
1TrainerBattlesWinsWin Rate
2Ash20130.65
3Misty860.75
4Brock1040.4
5Dawn16100.625
6Gary00#DIV/0!
=C2/B2

Gary has not had any battles yet. His formula in D6 is =C6/B6, which divides 0 by 0, so the result is #DIV/0!.

Wrap the division in IFERROR. Change the formula in D2, and fill it down to D6 again:

ABCD
1TrainerBattlesWinsWin Rate
2Ash20130.65
3Misty860.75
4Brock1040.4
5Dawn16100.625
6Gary00No battles
=IFERROR(C2/B2, "No battles")

The other win rates stay the same. Only the error is replaced.

Tip: Format column D as Percentage to show 0.65 as 65%. See Number Formats.


IFERROR Can Hide Mistakes

IFERROR hides every error, including errors that come from a mistake in your formula. Then the mistake is hard to notice.

Go back to the Pokemon table. This formula has a mistake: the column number is 5, but B2:E21 has only 4 columns. Type Squirtle in H3:

GH
3Search NameSquirtle
4TotalNot found
=IFERROR(VLOOKUP(H3, B2:E21, 5, FALSE), "Not found")

Squirtle is in the table, but the result is Not found. The real error is #REF!, because there is no column 5 in the range. IFERROR hides it.

Note: Make sure your formula works before you wrap it in IFERROR. Use IFERROR only for errors you expect, like a name that is not in the table.


IFNA: Catch Only #N/A

The IFNA function works like IFERROR, but it only catches the #N/A error. All other errors are still shown.

=IFNA(value, value_if_na)

Lookup functions return #N/A when they do not find the value. That makes IFNA a good choice for lookups: a missing name shows your message, but a mistake in the formula still shows an error.

Use IFNA with the same mistake as above. Squirtle is still in H3:

GH
3Search NameSquirtle
4Total#REF!
=IFNA(VLOOKUP(H3, B2:E21, 5, FALSE), "Not found")

Now you can see the #REF! error, and fix the column number to 4. After the fix, a name that is not in the table, like Pikachu, still returns Not found.

Note: IFNA is available in Excel 2013 and later.


See Also

XLOOKUP has its own if_not_found part, so you do not need IFERROR or IFNA around it.

IFERROR is often used together with VLOOKUP, HLOOKUP and INDEX and MATCH. To check conditions other than errors, use IF.


Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.