VLOOKUP
About this lesson
VLOOKUP searches the first column of a table for a value. Then it returns a value from the same row, in a column you choose.
- look up a value with VLOOKUP and return any column from its row.
- search for a code read from a cell or typed into the formula.
- say what FALSE does, and what leaving it off costs.
The idea
It takes four arguments: what to find, where to look, which column to return, and whether the match must be exact. People often leave off the fourth one, and it costs them. Without it, VLOOKUP assumes the first column is sorted. It returns the closest value below your search value. On an unsorted list it does not fail. It gives a wrong answer with no warning.
The third argument needs care too. It counts columns from the left edge of the table you gave it, not from column A. Give it B1:D6 and column 1 is B, not A.
The mistake to watch for
Leaving off the fourth argument. Without FALSE, VLOOKUP assumes the first column is sorted and returns the nearest smaller value. For codes, names and IDs, that is a wrong answer that looks right. Write FALSE every time, unless the table is a band table on purpose.
Read more about this
Where this comes up again
This lesson needs JavaScript to run. Everything below is the lesson in full, but you cannot type into the grid or be marked.
VLOOKUP finds a value in the first column of a table and returns something from that row.
In E2, type:
=VLOOKUP(F2,A1:D6,3,FALSE)
F2 is the code, A1:D6 the table, 3 the Unit price column, FALSE an exact match.
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | Code | Item | Unit price | Lead days | |||
| 2 | PR-100 | Business cards | 34.5 | 3 | PR-340 | ||
| 3 | PR-220 | A5 flyers | 62 | 5 | PR-455 | ||
| 4 | PR-340 | Roll banner | 128.75 | 7 | PR-100 | ||
| 5 | PR-455 | Vinyl sticker | 18.2 | 2 | |||
| 6 | PR-560 | Foam board | 41.9 | 4 | |||
| 7 | |||||||
| 8 |
Every step
-
VLOOKUPfinds a value in the first column of a table and returns something from that row. InE2, type:=VLOOKUP(F2,A1:D6,3,FALSE).F2is the code,A1:D6the table, 3 the Unit price column,FALSEan exact match. -
Only the third argument decides which column comes back. Read
=VLOOKUP(F3,A1:D6,4,FALSE)and say what it returns.F3holds PR-455, and the fourth column is Lead days. -
In
E4, return the item name for the code inF4. It is the same lookup, with the second column of the table. -
The lookup value does not have to be a cell. Text in quotation marks works too. In
E5, get the unit price for PR-560. Shape:=VLOOKUP("text",A1:D6,3,FALSE). -
A lookup is just a value, so it can go into a calculation. In
E7, find 3 times the price of the item inF2. Shape:=VLOOKUP(lookup,table,col,FALSE)*n. -
TRUEinstead ofFALSEfinds the nearest lower match, not an exact one. Read=VLOOKUP("PR-400",A1:D6,3,TRUE)and say what it returns. There is no PR-400 on the list.