Use IFERROR with VLOOKUP to Get Rid of #N/A Errors

Sumit Bansal
Written by

Sumit Bansal is the founder of TrumpExcel.com and a 13-time Microsoft Excel MVP. He started this site in 2013 to share his passion for Excel through easy tutorials, tips, and training videos, helping you master Excel, boost productivity, and maybe even enjoy spreadsheets!

Last updated

When using the VLOOKUP formula in Excel, sometimes you may end up with the ugly #N/A error. This happens when your formula can not find the lookup value.

In this tutorial, I will show you different ways to use IFERROR with VLOOKUP to handle these #N/A errors cropping up in your worksheet.

Using the combination of IFERROR with VLOOKUP allows you to show something meaningful in place of the #N/A error (or any other error for that matter).

I’ll also show you when the IFNA function is the better choice, and how the XLOOKUP function handles this without IFERROR at all.

Before getting into details on using this combination, let’s first quickly go through the IFERROR function and see how it works.

Follow along with the example file

IFERROR with VLOOKUP.xlsx

Download

IFERROR Function Explained

With IFERROR function, you can specify what should happen in case a formula or a cell reference returns an error.

Here is the syntax of the IFERROR function.

=IFERROR(value, value_if_error)
  • value: this is the argument that is checked for the error. In most cases, it is either a formula or a cell reference. When using VLOOKUP with IFERROR, the VLOOKUP formula would be this argument. If there’s no error, IFERROR returns the result of this argument as it is.
  • value_if_error: this is the value that is returned if there is an error. The following error types are evaluated: #N/A, #REF!, #DIV/0!, #VALUE!, #NUM!, #NAME?, and #NULL!.

The IFERROR function works in all current Excel versions, including 365, 2024, 2021, 2019, 2016, Mac, and the web.

Possible Causes Of VLOOKUP Returning a #N/A Error

VLOOKUP function may return a #N/A error due to any of the following reasons:

  1. The lookup value is not found in the lookup array.
  2. There is a leading, trailing, or double space in the lookup value (or in the table array).
  3. There is a spelling error in the lookup value or the values in the lookup array.

You can handle all these causes of error with the combination of IFERROR and VLOOKUP. However, you should keep an eye out for cause #2 and #3, and correct these in the source data instead of letting IFERROR handle these.

With a stray space or a spelling error, the formula shows your replacement text for a value that’s really in the list, so the real problem stays hidden.

You can treat leading, trailing, and double spaces using the TRIM function.

These three causes aren’t the only ones (numbers stored as text is another common one). If the value is clearly in your list and you still get the error, go through these 10 common fixes for VLOOKUP not working before you wrap the formula in IFERROR.

Also, #N/A isn’t the only error that IFERROR catches. It replaces other errors such as #REF! too, and that’s where the IFNA function comes in.

Note: IFERROR would treat an error irrespective of what caused it. If you only want to treat the errors caused by VLOOKUP not being able to find the lookup value, use IFNA instead.

That will make sure that errors other than #N/A are not treated and you can investigate these other errors.

IFNA would still hide a space or spelling problem though, because those return #N/A too.

Replacing VLOOKUP #N/A Error with Meaningful Text

Suppose you have a dataset as shown below, with student names and their scores in columns A and B, and I want to get the score for each name in column D using a formula in column E.

Student names and scores in columns A and B, five lookup names in column D, and empty result columns E and F

The formulas in this section look up all the names at once, which needs Excel 365, 2024, or 2021. If you have an older version, the IFERROR formula you need is further down.

Here is the plain VLOOKUP formula, which I’ve entered in cell E2:

=VLOOKUP(D2:D6,$A$2:$B$10,2,FALSE)
VLOOKUP formula in cell E2 returning scores for Brad, Sam, and Jack, and #N/A errors for Glen and Carrie

As you can see that the VLOOKUP formula returns an error for Glen and Carrie, as these lookup values are not in the list. There’s no need to copy this formula down, because it looks up all five names and spills the results by itself.

While this is a very small dataset, you may get huge datasets where you have to check the occurrence of many items. For every case when the value is not found, you will get a #N/A error.

Here is the formula you can use to get something meaningful instead of the #N/A error, entered in cell F2:

=IFERROR(VLOOKUP(D2:D6,$A$2:$B$10,2,FALSE),"Not Found")
IFERROR with VLOOKUP formula in cell F2 returning Not Found for Glen and Carrie

The above formula returns the text “Not Found” instead of the #N/A error. IFERROR takes each result from VLOOKUP, keeps it if it’s a real score, and swaps it for your text if it’s an error.

The cells below the formula need to be empty, otherwise you’ll get a #SPILL! error.

If you are using Excel 2019 or earlier, enter the below formula in cell F2 and then copy it down the range:

=IFERROR(VLOOKUP(D2,$A$2:$B$10,2,FALSE),"Not Found")

The dollar signs keep the table range fixed as you copy the formula, while D2 changes to D3, D4, and so on.

You can also use the same formula to return blank, zero, or any other meaningful text.

If you have Excel 365, 2024, or 2021, you can also do this without IFERROR at all, and I’ve covered that in the XLOOKUP section below.

Return Blank or 0 Instead of the VLOOKUP #N/A Error

Text like “Not Found” isn’t always what you want, so let’s see how to show a blank or a 0 instead.

Below is the same student list, and I want to get the score for each name in column D, with a blank in column E or a 0 in column F when the name isn’t found.

Student names and scores in columns A and B, five lookup names in column D, and empty Return Blank and Return 0 columns

Here is the formula that shows a blank when the name is not found. The two double quotes at the end are what make the cell look empty.

=IFERROR(VLOOKUP(D2:D6,$A$2:$B$10,2,FALSE),"")
IFERROR with VLOOKUP formula in cell E2 showing a blank for Glen and Carrie

And here is the formula that shows a 0 instead:

=IFERROR(VLOOKUP(D2:D6,$A$2:$B$10,2,FALSE),0)
IFERROR with VLOOKUP formula in cell F2 showing 0 for Glen and Carrie

If you are using Excel 2019 or earlier, enter the below formula in cell E2 to show a blank, and then copy it down the range:

=IFERROR(VLOOKUP(D2,$A$2:$B$10,2,FALSE),"")

To show a 0 instead, enter the below formula in cell F2 and then copy it down the range:

=IFERROR(VLOOKUP(D2,$A$2:$B$10,2,FALSE),0)

These two options look similar, but they behave very differently once you do math on the results. To show this, I’ve added two check rows below the results.

Check rows below the results showing averages of 77.7 and 46.6, and a #VALUE! error beside a result of 5

The two double quotes give you an empty text string, not a truly empty cell, and Excel can’t add a number to text. So =E3+5 tries to add 5 to Glen’s blank and returns a #VALUE! error, while =F3+5 returns 5.

That 5 has its own problem, because a 0 counts as a real score. =AVERAGE(F2:F6) returns 46.6 because Glen and Carrie are averaged in as zeros, while =AVERAGE(E2:E6) returns 77.7 because the AVERAGE function ignores the blank text cells.

So a blank is the better choice when a missing name shouldn’t count as a score, and a 0 is safer when later formulas add or subtract from these cells and a missing name really can count as zero.

Nesting VLOOKUP With IFERROR Function

Follow along with the example file

IFERROR with VLOOKUP.xlsx

Download

In case you are using VLOOKUP and your lookup table is fragmented on the same worksheet or different worksheets, you need to check the VLOOKUP value through all of these tables.

For example, in the dataset shown below, there are two separate tables of student names and the scores, and I want to get the score for each name in column G using a formula in column H.

Two separate tables of student names and scores, four lookup names in column G, and an empty Score column H

If I have to find the score of Grace in this dataset, I need to use the VLOOKUP function to check the first table, and if the value is not found in it, then check the second table.

Here is the nested IFERROR formula I can use to look for the value, entered in cell H2:

=IFERROR(VLOOKUP(G2:G5,$A$2:$B$5,2,FALSE),IFERROR(VLOOKUP(G2:G5,$D$2:$E$5,2,FALSE),"Not Found"))
Nested IFERROR and VLOOKUP formula in cell H2 returning 81, 76, Not Found, and 90

How this formula works:

  • VLOOKUP(G2:G5,$A$2:$B$5,2,FALSE) looks for each name in the first table. Jill is there, so her score of 76 comes back straight away.
  • The outer IFERROR steps in when a name isn’t in the first table. Instead of showing an error, it moves on to its second part, which is another IFERROR.
  • VLOOKUP(G2:G5,$D$2:$E$5,2,FALSE) then checks the second table. Grace and Sam are there, so you get 81 and 90.
  • “Not Found” is what’s left when a name is in neither table, which is what happens with Glen.

If you have more than two tables, keep adding one more IFERROR and VLOOKUP pair inside the formula for each extra table.

If you are using Excel 2019 or earlier, enter the below formula in cell H2 and then copy it down the range:

=IFERROR(VLOOKUP(G2,$A$2:$B$5,2,FALSE),IFERROR(VLOOKUP(G2,$D$2:$E$5,2,FALSE),"Not Found"))

IFERROR with VLOOKUP from Another Sheet

The same nesting works when your tables are on different worksheets.

In the example file, the students are split across two sheets named Class A and Class B, and on the Different Sheets tab, I want to get the score for each name in column A using a formula in column B.

Four student names in column A and an empty Score column B

Here is the formula, entered in cell B2 of the Different Sheets tab:

=IFERROR(VLOOKUP(A2:A5,'Class A'!$A$2:$B$5,2,FALSE),IFERROR(VLOOKUP(A2:A5,'Class B'!$A$2:$B$5,2,FALSE),"Not Found"))
Nested IFERROR and VLOOKUP formula in cell B2 looking in the Class A and Class B sheets and returning 81, 76, Not Found, and 90

It works just like the formula in the previous section, except that each table reference now starts with its sheet name. The single quotes are there because these sheet names have a space in them.

If you are using Excel 2019 or earlier, enter the below formula in cell B2 and then copy it down the range:

=IFERROR(VLOOKUP(A2,'Class A'!$A$2:$B$5,2,FALSE),IFERROR(VLOOKUP(A2,'Class B'!$A$2:$B$5,2,FALSE),"Not Found"))

Using VLOOKUP with IF and ISERROR (Versions prior to Excel 2007)

IFERROR function was introduced in Excel 2007 for Windows. If you’re using the prior versions, then IFERROR function will not work in your system.

You can replicate the functionality of IFERROR function by using the combination of the IF function and the ISERROR function. You may also run into this combination in older workbooks, so it’s useful to know what it does.

Let me quickly show you how to use the combination of IF and ISERROR instead of IFERROR. Below is the same student list, and I want to get the score for each name in column D using a formula in column E.

Student names and scores in columns A and B, five lookup names in column D, and empty IF and ISERROR and IFERROR columns

Enter the below formula in cell E2 and then copy it down the range:

=IF(ISERROR(VLOOKUP(D2,$A$2:$B$10,2,FALSE)),"Not Found",VLOOKUP(D2,$A$2:$B$10,2,FALSE))
IF and ISERROR formula with VLOOKUP in cell E2, copied down, returning Not Found for Glen and Carrie

The ISERROR part of the formula checks for the errors (including the #N/A error) and returns TRUE if an error is found and FALSE if not.

  • If it’s TRUE (which means that there is an error), the IF function returns the specified value (“Not Found” in this case).
  • If it’s FALSE (which means that there is no error), the IF function returns the result of the VLOOKUP.

Here is the same lookup using IFERROR, entered in cell F2 and copied down:

=IFERROR(VLOOKUP(D2,$A$2:$B$10,2,FALSE),"Not Found")
IFERROR with VLOOKUP formula in cell F2, copied down, returning the same results as the IF and ISERROR formula

Both formulas return the same results. The IFERROR version is shorter, because you only write the VLOOKUP once.

IFERROR Vs IFNA

IFERROR treats all kinds of errors while IFNA treats only the #N/A error. When handling errors caused by VLOOKUP, you need to make sure you’re using the right formula.

Use IFERROR when you want to treat all kinds of errors. Now an error can be caused by various factors (such as the wrong formula, misspelled named range, not finding the lookup value, and returning error value from the lookup table).

It wouldn’t matter to IFERROR and it would replace all these errors with the specified value.

Use IFNA when you want to treat only #N/A errors, which are more likely to be caused by VLOOKUP formula not being able to find the lookup value.

Let’s see the difference with the same student list, where I want to get the score for each name in column D using the formulas in columns E, F, and G. The IFNA function needs Excel 2013 or later.

Student names and scores in columns A and B, five lookup names in column D, and empty result columns E, F, and G

Here is the formula using IFNA, entered in cell E2:

=IFNA(VLOOKUP(D2:D6,$A$2:$B$10,2,FALSE),"Not Found")
IFNA with VLOOKUP formula in cell E2 returning Not Found for Glen and Carrie

When the formula is correct, it returns the same results as IFERROR. The difference shows up when something else is wrong with your formula, so let’s say I type 3 as the column number by mistake, even though the table only has two columns.

Here is that mistake wrapped in IFERROR, entered in cell F2:

=IFERROR(VLOOKUP(D2:D6,$A$2:$B$10,3,FALSE),"Not Found")
IFERROR with a wrong column number in cell F2 returning Not Found on every row

Every name in column F now shows “Not Found”, including Brad, Sam, and Jack, who are in the list. The formula is broken, but nothing on the sheet tells you that.

Here is the same mistake wrapped in IFNA, entered in cell G2:

=IFNA(VLOOKUP(D2:D6,$A$2:$B$10,3,FALSE),"Not Found")
IFNA with a wrong column number in cell G2 returning #REF! for Brad, Sam, and Jack, and Not Found for Glen and Carrie

Now Brad, Sam, and Jack show a #REF! error in column G, which is your signal that the column number is wrong. Glen and Carrie still show “Not Found”, because VLOOKUP can’t find these names and returns #N/A, the one error IFNA replaces.

If you are using Excel 2013, 2016, or 2019, enter the below correct IFNA formula in cell E2 and then copy it down the range:

=IFNA(VLOOKUP(D2,$A$2:$B$10,2,FALSE),"Not Found")

Using XLOOKUP Instead of IFERROR with VLOOKUP

If you have a newer version of Excel, you may not need a wrapper at all. Below is the same student list, and I want to get the score for each name in column D using a formula in column E.

Student names and scores in columns A and B, five lookup names in column D, and an empty XLOOKUP column

Here is the formula using the XLOOKUP function:

=XLOOKUP(D2:D6,$A$2:$A$10,$B$2:$B$10,"Not Found")
XLOOKUP formula in cell E2 returning Not Found for Glen and Carrie

The last argument is what XLOOKUP shows when it can’t find a match, so there’s no IFERROR or IFNA around it. It only steps in for a missing match, so like IFNA, it won’t hide other mistakes in your formula.

XLOOKUP is only available in Excel 365, 2024, and 2021. I think it’s far better than VLOOKUP, and you should move to it when your Excel version and sharing requirements allow it.

VLOOKUP still makes sense when a workbook must work in an older version that does not support XLOOKUP. If you want the full comparison, here’s VLOOKUP vs XLOOKUP.

So these are the different ways you can use IFERROR with VLOOKUP to get rid of #N/A errors. Just keep in mind that IFERROR hides every error, so make sure the formula is right before you wrap it.

I hope you found this Excel tutorial useful.

You May Also Find the Following Excel Tutorials Useful:

Sumit Bansal

Sumit Bansal

13x Microsoft Excel MVP

Hey! I'm Sumit Bansal, founder of trumpexcel.com and a Microsoft Excel MVP. I started this site in 2013 because I genuinely love Microsoft Excel (yes, really!) and wanted to share that passion through easy Excel tutorials, tips, and Excel training videos. My goal is straightforward: help you master Excel skills so you can work smarter, boost productivity, and maybe even enjoy spreadsheets along the way!

17 thoughts on “Use IFERROR with VLOOKUP to Get Rid of #N/A Errors”

  1. =IFERROR(VLOOKUP(E3,'[Customer Mapping.xlsx]main’!$A$1:$C$822,3,0)),IFERROR(VLOOKUP,(E3,'[Customer Mapping.xlsx]main’!$A$1:$C$822,3,0)),”L1/N5″))

    Can you let me know the error in this message

    Reply
  2. What is the result returned by VLOOKUP when both the columns has same value (i.e., blank)?

    I received “#N/A” when both the source cell and target cell has no values. Can someone help me here please?

    thanks in advance.

    Reply
    • I am using excel 2010, while using the formula it is showing the correct selection in the formula but it is not displaying the area we want but it is showing the entire formula again. can you help me?

      Reply
  3. i am using =IFNA(vlookup,0) in code but its reflected in excel as =ifna(vlookup,0) as i want value 0 where #N/A comes. because of that it gives me value as #NAME

    Reply
  4. I think it’s much better to use the IFNA function that works more or less like IFERROR, but with the really important difference that IFNA only get rid of the #N/A errors…

    Reply
      • No, IFNA is always the best solution with VLOOKUP, because only the #N/A are hidden, so it’s possible to detect all other errors: wrong range, wrong formula, misspelled name range and so on… With IFERROR you hide all this stuff and you cannot correct the errors…

        Reply
          • Hello Franz.. While I agree that IFNA is the better choice with VLOOKUP, it’s also dependent on the data structure and the output that decides what function should be used.

            As far as I know, IFNA is not available in 2007 and 2010 versions of Excel Windows. Instead of going the longer IF + ISNA, route, it’s easier to check the formula and make sure there are no errors in the formula or named range and go with IFERROR instead. Another example is of a recent dashboard i worked on, where the data I got itself had errors such as DIV and NA. Instead of going a 2-step process of checking with IFNA and then treating the DIV errors with IFERROR, it’s better to make sure the formula/named range is correct and then use IFERROR.

            Also, wrong range anyway returns NA error, so even IFNA wouldn’t help in that case.

            My point is, IFNA is better, but it’s not the only way to go.

  5. Good post but I do have an issue with IFERROR

    You may also be getting an error if the range looked up is too short narrow, or if the cell value returned (legitimately) is itself an error, or if the index is negative, or if the lookup range is unsorted and the last element in the VLOOKUP is omitted, or if the lookup value is an error, or maybe mistyped a range name or …
    What I’m getting at is that errors can occur for many reasons and defaulting the error response to “not found” may mean you’re going to overlook an incorrect formula

    Much better to anticipate the error (with a COUNTIF in this case) and deal with it properly

    IFERROR is a very dangerous thing to use in such a cavalier manner – beware

    jim

    Reply
    • Hey Jim.. I mentioned in the tutorial that there can be various reasons for errors and first it must be sorted at the data level instead of letting IFERROR handle it (covered in the ‘possible causes or error’ section).

      Also, the next step would always be to make sure the formula is created properly. There wouldn’t be any other way to handle misspelled named range or not having the proper data structure or not having the right lookup range, than to make sure it’s sorted in the first place.

      In case of approximate match, having the data sorted in an ascending order is a pre-requisite to use the VLOOKUP formula. That would anyway lead to wrong results (even in cases when the result is not an error).

      In case the formula returns a result that is an error, IFERROR would still be valuable in making the result more meaningful.

      The cases where this combination works well is when you get data download from a data set that have fixed formats and you need to perform lookup on such data.

      When used properly, IFERROR can be a really useful function.

      Reply

Leave a Comment

Get the FREE 51 Excel Tips Ebook

Enter your details and the free PDF is on its way to your inbox.

Hmm, that didn't go through. Please check your email and try again.

No spam. You'll also get my weekly Excel newsletter. Unsubscribe anytime.

Check your inbox!

The ebook is on its way to your email. It usually lands within a couple of minutes.