Sub topic 2
VLOOKUP: Search Key, Range, and Column Index
This chapter assumes you know how to enter formulas in Google Sheets and use cell and range references such as A2:C100. You should also know that $ creates an absolute reference, such as $A$2:$C$100.
What VLOOKUP does
A lookup finds related information by using a key. A key is a value that identifies a row, such as a product ID, employee number, or order code.
VLOOKUP searches for a key in the first column of a selected range. When it finds the key, it returns a value from another column in the same row.
For example, suppose your sheet contains this table:
| A | B | C |
|---|---|---|
| Product ID | Product name | Price |
| P-101 | Keyboard | 45 |
| P-102 | Mouse | 20 |
| P-103 | Monitor | 180 |
To return the price for product P-102, use:
=VLOOKUP("P-102", A2:C100, 3, FALSE)This formula searches for P-102 in column A. It returns the value from the third column of the range A2:C100, which is column C.
Understanding the syntax
The general form is:
=VLOOKUP(search_key, range, index, [is_sorted])Each argument has a specific role:
| Argument | Meaning | Example |
|---|---|---|
| `search_key` | The value to find | `"P-102"` or `E2` |
| `range` | The table containing the key and result | `A2:C100` |
| `index` | The column number to return, counted within the range | `3` |
| `is_sorted` | Whether to use approximate matching | `FALSE` |
The index argument counts from the left edge of the selected range, not from the whole sheet. In A2:C100, column A is 1, column B is 2, and column C is 3.
If the range is D2:G100, column D is 1 and column G is 4. The sheet column letters do not determine the index.
Using a cell as the search key
Hard-coding a key in a formula works for a single test, but a cell reference makes the formula reusable. If E2 contains P-102, use:
=VLOOKUP(E2, A2:C100, 3, FALSE)When you change the value in E2, the result updates automatically.
When copying the formula down, lock the table range so it does not move:
=VLOOKUP(E2, $A$2:$C$100, 3, FALSE)The $ signs make both the starting and ending references absolute.
How the lookup works
The formula follows this sequence:
The search column must be the first column in the range. For example, this formula searches column A and returns column C:
=VLOOKUP(E2, $A$2:$C$100, 3, FALSE)VLOOKUP cannot search column C and return a value from column A because the result column is to the left of the search column. The selected range must place the search column first.
Common mistakes
- Using the wrong index. In
A2:C100, the price column has index3, not the sheet column number. - Selecting a range whose first column does not contain the key.
- Omitting
FALSE. Without it, VLOOKUP uses approximate matching. - Allowing a table range to shift when copying a formula. Use absolute references such as
$A$2:$C$100. - Expecting text that looks similar to match. A hidden space or a number stored as text can prevent a match.
Exercise
Product IDs are in B2:B100, product names are in C2:C100, and prices are in D2:D100. Cell G2 contains the ID to find. Write a VLOOKUP formula that returns the price using an exact match and a fixed table range.
Show answer
=VLOOKUP(G2, $B$2:$D$100, 3, FALSE)