The VLOOKUP function
VLOOKUP looks down the first column of a table for a value, then reads across to another column on the same row. It's the classic way to pull a price, a name or a stock level from a list using a code.
For almost every lookup you want an exact match, so finish the formula with FALSE. The approximate mode, TRUE, is for sorted bands such as delivery charges or grade boundaries.
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
Arguments
- lookup_value
- What to look for, such as a product code. It is searched for in the first column of the table.
- table_array
- The table to search, starting with the column that holds the lookup values.
- col_index_num
- Which column of the table to return: 1 is the first column, 2 the second, and so on.
- range_lookupoptional
- FALSE for an exact match. TRUE, or leaving it out, finds the nearest value below in a sorted list.
Try it
=VLOOKUP(F2,A2:D6,3,FALSE) in G2. VLOOKUP finds P104 in column A, then returns the 3rd column of the table on that row: the price of marmalade, £2.95. Change F2 to another code to look up a different product.
G2
| A | B | C | D | E | F | G | H | I | J | K | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | Code | Product | Price | Stock | Code | Price | Order from | Delivery | |||
| 2 | P101 | Tea bags | £3.20 | 40 | P104 | £2.95 | £0.00 | £4.99 | |||
| 3 | P102 | Oat milk | £1.85 | 25 | £20.00 | £2.99 | |||||
| 4 | P103 | Porridge oats | £2.40 | 0 | £50.00 | £0.00 | |||||
| 5 | P104 | Marmalade | £2.95 | 12 | |||||||
| 6 | P105 | Crumpets | £1.10 | 30 | |||||||
| 7 | |||||||||||
| 8 |
Edit the formula in G2, or change the data, and press Enter.
More examples
| Formula | Result | What it does |
|---|---|---|
| =VLOOKUP("P102",A2:D6,2,FALSE) | Oat milk | Column 2 of the table holds the product name. |
| =VLOOKUP("P101",A2:D6,4,FALSE) | 40 | Column 4 is the stock level. |
| =VLOOKUP("P999",A2:D6,3,FALSE) | #N/A | The code isn't in the list, so VLOOKUP returns #N/A. Wrap it in IFERROR or IFNA to show a friendlier message. |
| =VLOOKUP(35,I2:J4,2,TRUE) | £2.99 | Approximate match on a sorted band table: £35 falls in the band starting at £20, so delivery is £2.99. |
Tips
- Lock the table with dollar signs,
$A$2:$D$6, before copying the formula down, or the range will slide with it. - VLOOKUP can only look to the right of the first column. To return something to the left, use XLOOKUP or INDEX with MATCH.
- Inserting a column inside the table changes which number you need for
col_index_num. XLOOKUP and INDEX/MATCH don't have this problem.
Common mistakes
- It returns a value from the wrong row, with no error.The last argument is missing, so VLOOKUP did an approximate match on an unsorted list. Add
FALSEfor an exact match. - #N/A even though the code is clearly in the list.One side is text and the other a number (a code like 1001 typed as text), or there's a hidden trailing space. Make the types match, or clean the data with TRIM.
- #REF! appears.
col_index_numis bigger than the number of columns intable_array. Count the columns in the range, not the sheet. - It works in the first row but breaks when copied down.The table reference moved. Use
$A$2:$D$6so it stays fixed.
Practise VLOOKUP with instant feedback
Type real formulas into a working spreadsheet and get told straight away whether they work.