VLOOKUP practice

Type a real VLOOKUP below. Get it wrong and you'll see why.

In F2, look up the price of the product ID in E2.

Syntax
VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
F2
fx
ABCDEF
1IDProductPriceFind IDPrice
2P-101Notebook4.50P-104
3P-102Stapler12.00
4P-103Desk lamp28.00
5P-104Mouse pad6.75
6P-105Monitor stand39.00
7P-106Cable ties3.20

How VLOOKUP works

Find a value in the first column of a table, then read across to the column you want.

=VLOOKUP(E2, A2:C7, 3, FALSE)

lookup_value
What you're searching for. Here: E2, the ID P-104.
table_array
The whole table. The ID must sit in its first column. Here: A2:C7.
col_index_num
Which column to return, counting from 1 inside the table. Price is 3.
[range_lookup]
FALSE for an exact match. Leave it out and Excel guesses the nearest value.

Use FALSE when you look up IDs, names or codes. Use TRUE only for ranges, like tax brackets or shipping bands, and only when the first column is sorted from smallest to largest.

#N/A

The ID isn't in the first column, or has a stray space. TRIM fixes the space.

Wrong column

Count columns inside table_array, not from column A of the sheet.

Unlocked range

Fill down and A2:C7 slides to A3:C8. Lock it: $A$2:$C$7.

Missing FALSE

Without it you can get a confident, wrong answer from the row above.

Numbers stored as text

104 and "104" don't match. Look for the green triangle in the corner.

XLOOKUP can look left, defaults to an exact match and doesn't need a column number: =XLOOKUP(E2, A2:A7, C2:C7). It's only in newer versions of Excel, and older workbooks are full of VLOOKUP, so learn both.

2
Return the product name for P-106 using the same table (A2:C7).
Show formula
=VLOOKUP("P-106", A2:C7, 2, FALSE)→ Cable ties

Product is the 2nd column of A2:C7, so col_index_num changes from 3 to 2.

3
Fix a lookup that returns #N/A because E2 contains a stray space ("P-102 ").
Show formula
=VLOOKUP(TRIM(E2), A2:C7, 3, FALSE)→ 12.00

TRIM strips leading and trailing spaces from the lookup value before VLOOKUP searches column A.

4
Lock the table range so the formula can be copied down from F2 to F10.
Show formula
=VLOOKUP(E2, $A$2:$C$7, 3, FALSE)→ 6.75

Dollar signs lock A2:C7 while E2 stays relative so each row looks up its own ID.

Why does VLOOKUP return #N/A when the value is clearly there?

The two values are not exactly the same, or the value is not in the first column of the table. Look for a stray space ("P-102 " is not "P-102"), a number stored as text, or a table that starts one column too far right. TRIM removes extra spaces, and the table must start at the column you search.

Can VLOOKUP look to the left?

No. VLOOKUP searches the first column of the table and can only return columns to its right. To look left, use XLOOKUP, for example =XLOOKUP(E2, A2:A7, C2:C7), or INDEX with MATCH.

Will VLOOKUP come up in an Excel interview test?

Lookups are one of the most common tasks in Excel skills tests, usually next to SUMIF, IF and basic formatting. Practise until you can write a VLOOKUP with an exact match without checking the syntax, and know what #N/A means.