Professional Documents
Culture Documents
condition in Excel. You will also learn how to use IF ISNA VLOOKUP formulas to replace #N/A
errors with your own text, zero or blank cell.
Whilst the VLOOKUP and IF functions are useful on their own, together they deliver even more
valuable experiences. This tutorial implies that you remember the syntax of the two functions
well, otherwise you may want to brush up on your knowledge by following the above links.
Translated in plain English, the formula instructs Excel to return True if Vlookup is true (i.e.
equal to the specified value). If Vlookup is false (not equal to the specified value), the formula
returns False.
Below you will a find a few real-life uses of this IF Vlookup formula.
Let's say, you have a list of items in column A and quantity in column B. You are creating a
dashboard for your users and need a formula that would check the quantity for an item in E1 and
inform the user whether the item is in stock or sold out.
You pull the quantity with a regular Vlookup with exact match formula like this:
=VLOOKUP(E1,$A$2:$B$10,2,FALSE)
Then, write an IF statement that compares Vlookup's result with zero, and returns "No" if it is
equal to 0, "Yes" otherwise:
=IF(VLOOKUP(E1,$A$2:$B$10,2,FALSE)=0,"No","Yes")
Instead of Yes/No, you can return TRUE/FALSE or In Stock/Sold out or any other two choices.
For example:
You can also compare the value returned by Vlookup with sample text. In this case, be sure to
enclose a text string in quotation marks, like this:
=IF(VLOOKUP(E1,$A$2:$B$10,2)="sample text",TRUE,FALSE)
Another typical example of Vlookup with If condition in Excel is comparing the Vlookup output
with a value in another cell. For example, we can check if it's greater than or equal to a number
in cell G2:
=IF(VLOOKUP(E1,$A$2:$B$10,2)>=G2,"Yes!","No")
And here is our If formula with Vlookup in action:
In a similar fashion, you can use any other logical operator together with a cell reference in your
Excel If Vlookup formula.
To compare each cell in the target column with another list and return True or Yes if a match is
found, False or No otherwise, use this generic IF ISNA VLOOKUP formula:
If Vlookup results in the #N/A error, the formula returns "No", meaning the lookup value is not
found in the lookup list. If the match is found, "Yes" is returned. For example:
=IF(ISNA(VLOOKUP(A2,$D$2:$D$4,1,FALSE)),"No","Yes")
If your business logic requires the opposite results, simply swap "Yes" and "No" to reverse the
formula's logic:
=IF(ISNA(VLOOKUP(A2,$D$2:$D$4,1,FALSE)),"Yes","No")
Taking our example further, let's calculate the commission of a specific seller (F1) depending on
their effectiveness: 20% commission for those who made $200 and more, 10% for everyone else.
For this, you check if the value returned by Vlookup is greater than or equal to 200, and if it is,
multiply it by 20%, otherwise by 10%:
Naturally, you can type any text you like instead of "Not found".
Supposing, you have a list of seller names in one column and sales amounts in another column.
Your task is to pull a number corresponding to the name the user enters in F1. If the name is not
found, display a message indicating so.
With the names in A2:A10 and amounts C2:C10, the task can be fulfilled with the following If
Vlookup formula:
If the lookup value is not found, the Not found message appears instead of the #N/A error:
The formula's logic is very simple: you use the ISNA function to check Vlookup for #N/A errors.
If an error occurs, ISNA returns TRUE, otherwise FALSE. The above values go to the logical
test of the IF function, which does one of the following:
Tip. If you'd like to trap all sorts of errors, not only #N/A, use VLOOKUP in combination with
the IFERROR function. More details can be found here: IFERROR VLOOKUP in Excel.
IF(ISNA(VLOOKUP(…)), 0, VLOOKUP(…))
=IF(ISNA(VLOOKUP(F2,$A$2:$C$10,3,FALSE)), 0, VLOOKUP(F2,$A$2:$C$10,3,FALSE))
In the recent versions of Excel 2016 and 2013, you can use the IFNA Vlookup combination
again:
=IFNA(VLOOKUP(I2,$A$2:$C$10,3, FALSE), 0)
For example, you have order numbers in column A and seller names in column B. You are
looking for a formula to pull the order number for a specific seller.
Vlookup cannot be used in this case because it cannot search from right to left. Index Match will
work without a hitch as long as the lookup value is found in the lookup column. If not, a #N/A
error will show up. To replace the standard error notation with your own text, nest Index Match
inside IF ISNA:
=IF(ISNA(INDEX(A2:A10, MATCH(F1, $B$2:$B$10, 0))), "Not found", INDEX(A2:A10,
MATCH(F1, $B$2:$B$10, 0)))
In Excel 2016 and 2016, you can use IFNA instead of IF ISNA to make the formula more
compact: