VLOOKUP is one of the most misunderstood functions in Google Sheets. It allows you to search through and link together two sets of data in your spreadsheet with a single search value. Here’s how to use it.
Unlike Microsoft Excel, there’s no VLOOKUP wizard to help you in Google Sheets, so you have to type the formula manually.
How VLOOKUP Works in Google Sheets
VLOOKUP might sound confusing, but it’s pretty simple once you understand how it works. A formula that uses the VLOOKUP function has four arguments.
The first is the search key value you’re looking for, and the second is the cell range you’re searching (e.g., A1 to D10). The third argument is the column index number from your range to be searched, where the first column in your range is number 1, the next is number 2, and so on.
The fourth argument is whether the search column has been sorted or not.
The final argument is only important if you’re looking for the closest match to your search key value. If you’d rather return exact matches to your search key, you set this argument to FALSE.
Here’s an example of how you might use VLOOKUP. A company spreadsheet might have two sheets: one with a list of products (each with an ID number and price), and a second with a list of orders.
You can use the ID number as your VLOOKUP search value to find the price for each product quickly.
One thing to note is VLOOKUP can’t search through data to the left of the column index number. In most cases, you either have to disregard the data in columns to the left of your search key or place your search key data in the first column.
Using VLOOKUP on a Single Sheet
For this example, let’s say you have two tables with data on a single sheet. The first table is a list of employees’ names, ID numbers, and birthdays.
In a second table, you can use VLOOKUP to search for data that uses any of the criteria from the first table (name, ID number, or birthday). In this example, we’ll use VLOOKUP to provide the birthday for a specific employee ID number.
The appropriate VLOOKUP formula for this is
=VLOOKUP(F4, A3:D9, 4, FALSE).
To break this down, VLOOKUP uses the F4 cell value (123) as the search key and searches the range of cells from A3 to D9. It returns data from column number 4 in this range (column D, “Birthday”), and, as we want an exact match, the final argument is FALSE.
In this case, for ID number 123, VLOOKUP returns a birthdate of 19/12/1971 (using the DD/MM/YY format). We’ll expand this example further by adding a column to table B for surnames, making it link the birthday dates to actual people.
This requires only a simple change to the formula. In our example, in cell H4,
=VLOOKUP(F4, A3:D9, 3, FALSE)searches for the surname that matches ID number 123.
Instead of returning the birthdate, it returns the data from column number 3 (“Surname”) matched to the ID value located in column number 1 (“ID”).
Use VLOOKUP with Multiple Sheets
The example above used a set of data from a single sheet, but you can also use VLOOKUP to search data across multiple sheets in a spreadsheet. In this example, the information from table A is now on a sheet called “Employees,” while table B is now on a sheet called “Birthdays.”
Instead of using a typical cell range like A3:D9, you can click on an empty cell, and then type:
=VLOOKUP(A4, Employees!A3:D9, 4, FALSE).
When you add the name of the sheet to the beginning of the cell range (Employees!A3:D9), the VLOOKUP formula can use the data from a separate sheet in its search.
Using Wildcards with VLOOKUP
Our examples above used exact search key values to locate matching data. If you don’t have an exact search key value, you can also use wildcards, like a question mark or an asterisk, with VLOOKUP.
For this example, we’ll use the same set of data from our examples above, but if we move the “First Name” column to column A, we can use a partial first name and an asterisk wildcard to search the surnames of employees.
The VLOOKUP formula to search for surnames using a partial first name is
=VLOOKUP(B12, A3:D9, 2, FALSE); your search key value goes in cell B12.
In the example below, “Chr*” in cell B12 matches the surname “Geek” in the sample lookup table.
Searching for the Closest Match with VLOOKUP
You can use the final argument of a VLOOKUP formula to search for either an exact or closest match to your search key value. In our previous examples, we searched for an exact match, so we set this value to FALSE.
If you want to find the closest match to a value, change VLOOKUP’s final argument to TRUE. As this argument specifies whether a range is sorted or not, make sure your search column is sorted from A-Z, or it won’t work correctly.
In our table below, we have a list of items to buy (A3 to B9), along with item names and prices. They’re sorted by price from lowest to highest. Our total budget to spend on a single item is $17 (cell D4). We used a VLOOKUP formula to find the most affordable item on the list.
The appropriate VLOOKUP formula for this example is
=VLOOKUP(D4, A4:B9, 2, TRUE). Because this VLOOKUP formula is set to find the nearest match lower than the search value itself, it can only look for items cheaper than the set budget of $17.
In this example, the cheapest item under $17 is the bag, which costs $15, and that’s the item the VLOOKUP formula returned as the result in D5.
- › How to Use SUMIF in Google Sheets
- › How to Use INDEX and MATCH in Google Sheets
- › How to Fix a Formula Parse Error in Google Sheets
- › How to Group and Ungroup Rows and Columns in Google Sheets
- › How to Round Numbers in Google Sheets
- › The Fastest Way to Update Data in Google Sheets
- › How to Use XLOOKUP in Google Sheets
- › Notepad++ Can Handle Your Huge Text Files Again