How to Use VLOOKUP with IF Statement in Google Sheets

Combining the VLOOKUP function with the IF statement is sometimes required if you want to look for specific values or data in Google Sheets. In this article, we will show how to use VLOOKUP with an IF statement in Google Sheets easily and effectively.


A Sample of Practice Spreadsheet

Download this spreadsheet to practice yourself.


2 Examples of Using VLOOKUP with IF Statement in Google Sheets

VLOOKUP means vertical lookup. VLOOKUP lets you look for a particular value down the first column in a range of cells. This is what the formula looks like in Google Sheets:

VLOOKUP(search_key, range, index, [is_sorted])

IF function in Google Sheets is used to check a condition and then based on it, returns a value if the condition is TRUE, or else returns another value if the condition is FALSE. This is what the formula looks like in Google Sheets:

IF(logical_expression, value_if_true, value_if_false)

1. Performing Lookup from Two or More Tables

The VLOOKUP function can be used with the IF function to fetch data from 2 different tables. We have a dataset with two tables of two different shops named Shop A and Shop B. We will use the VLOOKUP function along with the IF function to return the Price of Apple from these two tables.

dataset for performing vlookup with if statement from two tables in google sheets

Steps:

  • First, go to the cell where you want to return data. In our example, we go to cell C14.

select cell to show result

  • Then, insert the VLOOKUP function.

input vlookup function

  • After that, insert the value that you want to look for followed by a Comma. We kept the value that we want to look for in a different cell. So we type C13.

input lookup value

  • Now, Insert the IF function.

input if function to vlookup with if statement in google sheets

  • Next, input the logical expression based on which the IF function will return the value. We kept the shop names in n a separate cell to easily formulate the formula. So, we type C12=B4 as we want to match the shop names and return the value if it finds a match.

input logical expression

  • Then, type the value that you want to show if the IF function finds a match. We want the IF function to return data from range B6:C10 if the value in cell C12 matches the value in cell B4, so we type B6:C10.

input the value to show if true

  • After that, type the value that you want to show if the IF function does not find a match. We want the IF function to return data from range E6:F10 if the value in cell C12 does not match the value in cell B4, so we type E6:F10.

input the value to show if false

  • Then, close parentheses for the IF function followed by a Comma to separate the two functions.

input comma to separate functions

  • After that, input the column number from which we want the VLOOKUP to fetch data if the IF function finds a match. We type 2 as the data we want to return is in column 2 of the data table.

input column number

  • Then, type 0 or FALSE to get an exact match.

input false to get an exact match

  • This is how the final formula looks:
=VLOOKUP(C13,IF(C12=B4,B6:C10,E6:F10),2,0)

final formula to use vlookup with if function in google sheets

  • Finally, press ENTER to show the value of Apple from Shop A.

final result after using vlookup with if function in google sheets

  • You can look for the price of Apple from Shop B by simply changing the shop name to Shop B in cell C12.

final result after using vlookup with if function in google sheets

Read More: How to VLOOKUP Between Two Google Sheets (2 Ideal Examples)


Similar Readings


2. Using Comparison Operators

Comparison operators such as Greater than (>) and Less than (<) can be used with the VLOOKUP function and the IF function to show some TRUE or FALSE results.

We have a dataset with Employee Name and their Sales Amount. If any one of the employees made a sale of more than $200 then, he will receive a bonus. We will use the IF function with the VLOOKUP to show if Daniel will receive a bonus or not.

dataset for using comparison operators with vlookup and if functions in google sheets

Steps:

  • First, go to the cell where you want to show the result. For our example, we go to cell C13.

select cell where to show result

  • Then, type in the following formula:
=IF(VLOOKUP(C12,B5:C10,2,0)>200,"Yes","No")

formula to use comparison operators with vlookup and if statement in google sheets

Formula Explanation:

  • C12 is the data that we want to match with the VLOOKUP The data in cell C13 is Daniel as we have created a Drop-Down list in cell C13 with the Employee Names.
  • B5:C10 is the range of the table where the data we are looking up is located.
  • 2 is the column number of the data that we want the VLOOKUP to return if it finds a match.
  • 0 is used because we want an exact match for the data. You can even use FALSE instead of 0.
  • >200 is the condition for the IF function based on which the IF function will return data.
  • “Yes” is the text we want the IF function to show if the value we looked up is greater than 200.
  • “No” is the text we want to show if the value is not greater than 200.
  • Finally, press ENTER to show the result. We can see that Daniel made a sale of more than $200, so he will receive a bonus.

final result after using comparison operators with vlookup and if statement in google sheets

  • We can select another employee from the drop-down list and check if he will receive a bonus or not. We select Charlie and see that he will not receive a bonus.

final result after using comparison operators with vlookup and if statement in google sheets

Read More: How to Use VLOOKUP with Drop Down List in Google Sheets


Conclusion

In this article, we showed you how to use the VLOOKUP function with an IF statement in Google Sheets with two different examples. Keep practicing the examples that we have shown here for a better understanding of the concept. We hope this article was useful to you to help you.

Also, check out other articles on OfficeWheel to keep on improving your Google Sheets work knowledge.


Related Articles

Maruf Niaz

Maruf Niaz

My Name is Niaz. As a regular Google Sheets user, I have a good understanding of the users' needs and bad experiences. In my articles, I will share my knowledge which I hope, will be helpful to you. My latest educational degree was BSc in Textile Engineering from Bangladesh University of Textiles.

We will be happy to hear your thoughts

Leave a reply

OfficeWheel
Logo