How to Use the VLOOKUP Function in Google Sheets | Search a Table Vertically for Matching Data
How to Use the VLOOKUP Function
The VLOOKUP function searches for a key in the leftmost column of a specified range and returns the value in a specified column number from the matching row. It is widely used for linking tables, such as looking up unit prices from a product master table.
Syntax
=VLOOKUP(search_key, range, index, [is_sorted])
- search_key: The value or cell reference to search for (required).
- range: The entire table to search. Make sure the column containing
search_keyis the leftmost column of this range (required). - index: The column number (counting from
1as the leftmost column ofrange) from which to return a value (required). - is_sorted: Specify
FALSE(or0) for an exact match, orTRUE(or1) for an approximate match (optional, though explicitly settingFALSEis recommended).
Table Example
Here is an example of automatically retrieving the "Product Name" into Column B based on the "Product ID" in Column A from the "Product Master" in Columns D–E.
| Row | Column A (Product ID) | Column B (Product Name) | Column C | Column D (Master ID) | Column E (Master Product Name) |
|---|---|---|---|---|---|
| 1 | Product ID | Product Name | Master ID | Master Product Name | |
| 2 | P002 | =VLOOKUP(A2, $D$2:$E$4, 2, FALSE) |
P001 | Wireless Mouse | |
| 3 | P003 | =VLOOKUP(A3, $D$2:$E$4, 2, FALSE) |
P002 | Mechanical Keyboard | |
| 4 | P001 | =VLOOKUP(A4, $D$2:$E$4, 2, FALSE) |
P003 | 4K Monitor |
- Row 2 formula:
=VLOOKUP(A2, $D$2:$E$4, 2, FALSE)→ Result:Mechanical Keyboard - Row 3 formula:
=VLOOKUP(A3, $D$2:$E$4, 2, FALSE)→ Result:4K Monitor
Tip: Use an absolute reference like $D$2:$E$4 so the lookup range does not shift when copying the formula down to other rows.
Common Errors and Notes
- Search key not found (
#N/Aerror): An#N/Aerror occurs ifsearch_keydoes not exist in the leftmost column of the master table, if there are extra leading or trailing spaces, or if data types differ (such as the number100vs. the text"100"). Wrap the formula inIFERRORif you want to display a blank cell or"Not Found"when no match is found. - Out-of-bounds index (
#REF!error): If you specify a columnindexlarger than the number of columns inrange, a#REF!error occurs. - Formulas breaking when columns are inserted or deleted: Inserting a column inside the master table does not automatically update the hardcoded
indexnumber, causing the wrong column to be returned. UseXLOOKUPif you want formulas that remain resilient to column insertions.
Frequently Asked Questions
Q. What should I specify for the 4th argument (is_sorted) of VLOOKUP?
A. When searching for an exact match such as a product code or employee ID, always specify "FALSE" (or "0"). If omitted, it defaults to "TRUE (approximate match)", which can return unintended values.
Q. Can VLOOKUP retrieve values from a column to the left of the search key?
A. No, VLOOKUP searches the "leftmost column" of the specified range and can only return values from columns to its right. To retrieve values from a column to the left, use XLOOKUP or a combination of INDEX and MATCH.