The tutorial shows how to combine VLOOKUP and IF function together to v-lookup with if 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.
Vlookup with If statement: return True/False, Yes/No, etc.
One of the most common scenarios when you combine If and Vlookup together is to compare the value returned by Vlookup with a sample value and return Yes / No or True / False as the result.
In most cases, the following generic formula would work nicely:
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.
Example 1. Look up a specific value
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:
=IF(VLOOKUP(E1,$A$2:$B$10,2)=0,"Sold out","In stock")
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)
Example 2. Compare Vlookup result with another cell
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.
Example 3. Vlookup values in a shorter list
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")
Excel If Vlookup formula to perform different calculations
Besides displaying your own text messages, If function with Vlookup can perform different calculations based on the criteria you specify.
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%:
=IF(VLOOKUP(F1,$A$2:$C$10,3,FALSE )>=200, VLOOKUP(F1,$A$2:$C$10,3,FALSE)*20%, VLOOKUP(F1,$A$2:$C$10,3,FALSE)*10%)
Where A2:A10 are seller names and C2:C10 are sales.
IF ISNA VLOOKUP to hide #N/A errors
If the VLOOKUP function cannot find a specified value, it throws an #N/A error. To catch that error and replace it with your own text, embed a Vlookup formula in the logical test of the IF function, like this:
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(ISNA(VLOOKUP(F1,$A$2:$C$10,3,FALSE)), "Not found", VLOOKUP(F1,$A$2:$C$10,3,FALSE))
If the name is found, a corresponding sales amount is returned:
If the lookup value is not found, the Not found message appears instead of the #N/A error:
How this formula works
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:
- If the logical test is TRUE (#N/A error), your message is displayed.
- If the logical test is FALSE (lookup value is found), Vlookup returns a match normally.
IFNA VLOOKUP in newer Excel versions
Beginning with Excel 2013, you can use the IFNA function instead of IF ISNA to catch and handle #N/A errors:
In our example, the formula would take the following shape:
=IFNA(VLOOKUP(F1,$A$2:$C$10,3, FALSE), "Not found")
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.
Excel Vlookup: if not found return 0
When working with numerical values, you may want to return a zero when the lookup value is not found. To have it done, use the IF ISNA VLOOKUP formula discussed above with a little modification: instead of a text message, supply 0 in the value_if_true argument of the IF function:
In our sample table, the formula would go as follows:
=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)
Excel Vlookup: if not found return blank cell
This is one more variation of the "Vlookup if then" statement: return nothing when the lookup value is not found. To do this, instruct your formula to return an empty string ("") instead of the #N/A error:
Below are a couple of complete formula examples:
For all Excel versions:
=IF(ISNA(VLOOKUP(F2,$A$2:$C$10,3,FALSE)), "", VLOOKUP(F2,$A$2:$C$10,3,FALSE))
For Excel 2016 and Excel 2013:
=IFNA(VLOOKUP(F2,$A$2:$C$10,3, FALSE), "")
If with Index Match - left vlookup with If condition
Experienced Excel users know that the VLOOKUP function is not the only way to do vertical lookup in Excel. The INDEX MATCH combination can also be used for this purpose and it's even more powerful and versatile. The good news is that Index Match can work together with IF in exactly the same way as Vlookup.
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:
=IFNA(INDEX(A2:A10, MATCH(F1, $B$2:$B$10, 0)), "Not found")
In a similar manner, you can use Index Match in other If formulas.
This is how you use Vlookup and IF statement together in Excel. To have a closer look at the formulas discussed in this tutorial, you are welcome to download our sample workbook below. I thank you for reading and hope to see you on our blog next week!
Practice workbook for download
Excel IF Vlookup - formula examples (.xlsx file)
375 comments
Hi...
I have list of employees details with unique employee id in one sheet and in another sheet i have only employee id. If i type Resigned against one worker in sheet 1 means that workers code should be highlighted in sheets 2..pls suggest any formulas
I have a list of sales with sold date for different months.
I need a formula to pull sales by month.
any ideas?
Hi,
I have query regarding find/search and vlookup.
I want find specific text from cell (string) and retrieve data from vlookup table by using this specific text.
e.g. “This is a boy” or “This is a girl” is in one cell.(there will more than 100 sentences) In Vlookup table Boy = Male and girl = Female.
I want display Male or Female in another cell of same sheet depends on cell string contains boy or girl.
Regards,
Pradeep
thanks rajesh peshiya for your interest in my problem solution,below is format of my data and requirement.
SID-Sept SID-Oct (comparison)"
10910 10910 Existing Student
9116 9116 Existing Student
11229 11229 Existing Student
11769 11769 Existing Student
11066 12346 New Addmission
6386 10967 New Addmission
11424 5662 New Addmission
11770 New Addmission
9988 New Addmission
Stuck Off
Stuck Off
Stuck Off
Common means old student
unirque in Sept means new addmission
Not found in Oct means Struck Off
My requirement Summary
Opening Strenght(1-10-18) 7
Add New Addmission 5
Less S/Off -3
Closing Strength(30-10-18) 9
I want to compare two columns for comparing students if there is new admission or left school. I need the result in following month in a separate column. That column should contain three words: Enrolled in previous month(if found in both months), new addmission( if found unique), SLC/Struck Off(if not found at all in following month). I need to know the new entrants and leavers, so that I add and subtract these with opening strength(previous month) to get closing strength balance. Duplicate conditional highlights and leaves unqiue,but those who left the school will not be at all in the following month(second column). but it is of no use for me. If any vlookup with three condition is there, it will be fine.
Hi. I have two spreadsheets with a list of more than 4k accounts each. I use vlookup with conditional formatting to determine if the same account number is on both sheets. But what I also need to do is, once it is established that the account number is on both sheets, update the balance on one sheet to the other on each account that is matched. Can you help me?
Thanks
good examples
Hello!
i am having problems in using following formula, condition is True we get result correct but condition is False we get error. kindly help, pl.
IF(S2=VLOOKUP(S2,Reference!$Q$9:$R$28,1,0),VLOOKUP(S2,Reference!$Q$9:$R$28,2,0),N2)
Hi,
Could we do 'IF combined VLOOKUP' search a lot of data where located from more than one tabs? if possible how do I do this?
thanks in advance.
Hi Rossa,
It sounds like you need to do sequential, or chained, Vlookups. This can be done by nesting several IFERROR VLOOKUP formulas into each other. An example can be found here: How to do sequential Vlookups in Excel.
Hello,
I have a question for you. Let's say I have the following content:
Cell A1: "I love puppies"
Cell A2: "I am a fan of dogs"
Cell A3: "Cats are awesome"
Cell A4: "Kittens are my favorite"
I want a formula that will see if a cell contains the words "puppies" and "dogs" and return the result "Dog Fan"
AND
I want the formula to see if a cell contains the words "Cats" and "Kittens" and return the result "Cat Fan" - how do I do this?
Hi i am trying to set up a vlookup conditional formula where if value is >=1 it should add 5 to the value and if it is 0 , then it should return 0 but i tried to set a =if(vlookup.....)formula and for 0 it is returning #N/A, Please help
Hi
How do i use the VLOOKUP and IF function to help me calculate my table whereby if a duplicate value is present then the function will help to average out these duplicate values based on the number of duplicate values there is e.g ( 3 & 3 = 3/2=1.5 , 3,3,3 = 3/3 = 1)
sorry my question was like this
I am looking for a value as below
look up the cell value =3300.01,0,VLOOKUP(N74,'Pay As You Earn'!$A:$N,14))
above formula is giving the correct value up to 12,785.00
but amount beyond 12,785.00 that its giving value 0
and
2) =IF(VLOOKUP(N75,'Pay As You Earn'!$A:$N,14,0)<=3300.01,0,VLOOKUP(N75,'Pay As You Earn'!$A:$N,14))
Where as the above formula is giving correct value beyond amount 12785.00
but below amount 12785.00 its giving 0
please see and inform the reason if you want i can share the excel workbook for finding exact cause.
Thanks.
I am looking for a value as below
look up the cell value =3300,0,VLOOKUP(N74,'Pay As You Earn'!$A:$N,14))
above formula is giving the correct value up to 12785.00
but after that its giving value 0
2) =IF(VLOOKUP(N75,'Pay As You Earn'!$A:$N,14,0)<=3300.01,0,VLOOKUP(N75,'Pay As You Earn'!$A:$N,14))
Where as the above formula is giving value 0 up to 12785.00
but after that its giving the correct value
please see and inform the reason if you want i can share the excel workbook for finding exact cause.
Thanks.
I have a main dataset of about 500,000 line items. I want to lookup the items from 3 different datasets. Each of these datasets has got about 200,000 line items. I want to use the if and vlookup function to return a " Yes" or "No" answer.
How can I use the if and vlookup formula using multiple data tables to return a "Yes" or "No" answer
In Excel, I have 2 sheets. One is titled "Equipment" and the other is "Technicians". What I would like to do is, on the Technicians sheet, In cell F3, I would like it to look on sheet "Equipment" from the range of I2:I17 and look for Gene? If Gene is found, then display the data from the corresponding cell in range A2:A17. This should be displayed in cell F3 on Technicians sheet. Any help would be appreciated!
Good afternoon,
I have emailed support@ablebits.com with a file (AJB Test Data) that I need help with please. I currently have a long IF calculation running over many columns to obtain the correct data that I need, but there must be a shorter way of doing it using Vlookup or Index Match maybe? In the Data Tab I need to use columns A and B to look up the corresponding column and cell on the Data 2 tab, then place the answer in the Data Tab, column C against the corresponding row. In essence there are two cells to match up to locate the correct data. In my working copy there may be up to three cells to match! Help would be greatly appreciated. Thank you.
Hello, I have problem to merge my data, can you help me, please? Can I get your email to send you my data? Thank you :)
I'm not sure if this is possible, but figured I would ask. I have 1 column (354 rows) that include a unique query string in each and want to search that string for an account number (5-6 digits long). I have another column that lists all the possible account numbers to do a lookup against. Next to that column, I have a column with account names for each account number. I'm looking to see if it's possible in new column to return the account name associated with particular account number IF that account number is found in the query string. Let me know if I explained what I'm trying to do correctly and if this is possible without parsing out the account number from the long query string.