ExcelyourTraining

Home › Blog

How to use VLOOKUP in Excel: a step-by-step guide with a rand price list

VLOOKUP is the formula people ask about most once they start using Excel at work. You have a list of product codes, and you need the price for each one without scrolling and copying by hand.

This guide shows you how to use VLOOKUP in Excel with one small worked example. By the end you'll be able to write the formula from memory, fill it down a whole column, pull prices from another sheet, and decide when XLOOKUP is the better tool.

The example: a small shop's price list

Say Pieter runs a small appliance shop in Durban. His price list sits in columns A to C:

A B C
1 Code Product Price
2 A101 Kettle R349
3 A102 Toaster R429
4 B205 Steam iron R299
5 C310 Blender R899
6 C315 Air fryer R1 499

A customer, Thandi, sends an order with only the codes. Pieter types them into column E and wants the price next to each one in column F:

E F
1 Code Price
2 C310 ?
3 A101 ?
4 B205 ?

That's exactly the job VLOOKUP does. It takes a value, finds it in the first column of a table, and returns something from the same row further to the right.

The VLOOKUP formula, piece by piece

VLOOKUP has four parts:

=VLOOKUP(lookup_value, table_array, col_index_num, range_lookup)

In plain words:

  1. What are you looking for? The code in E2.
  2. Where is the table? A2:C6, the price list without its header.
  3. Which column holds the answer? Count from the left edge of the table. Code is 1, Product is 2, Price is 3.
  4. Exact or approximate match? For codes, you want an exact match, so you type FALSE.

Put together, the formula in F2 is:

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

Press Enter and you get R899, the price of the blender.

Why FALSE matters more than it looks

The fourth argument is optional, and that's the trap. If you leave it out, Excel uses approximate match (TRUE). Microsoft's own documentation confirms that approximate match is the default.

Approximate match is built for sorted bands, such as commission tiers, where you want "the closest value that isn't bigger than this one". On a list of product codes it can quietly return the price of the wrong product, with no error to warn you.

So make it a habit. When you're matching codes, names or ID numbers, always end with FALSE (or 0, which means the same thing). With FALSE, if the code isn't in the list, you get #N/A, which is far better than a believable wrong price.

Fill the formula down without breaking it

You don't want to type the formula three times. Select F2 to F4 and fill down with Ctrl+D (Windows) or Cmd+D (Mac), or drag the small square at the bottom-right corner of F2.

There's one catch. As the formula moves down a row, Excel moves every reference with it. E2 becoming E3 is what you want. A2:C6 becoming A3:C7 is not, because the table now misses the kettle in row 2.

Lock the table with dollar signs so it stays put:

=VLOOKUP(E2,$A$2:$C$6,3,FALSE)

The quickest way is to click inside A2:C6 in the formula bar and press F4 (Windows) or Cmd+T (Mac). The dollar signs appear for you.

VLOOKUP from another sheet

In real workbooks the price list usually lives on its own sheet. The formula works the same way. You add the sheet name and an exclamation mark in front of the range:

=VLOOKUP(E2,Prices!$A$2:$C$6,3,FALSE)

If the sheet name has a space in it, such as "Price List", wrap it in single quotes: 'Price List'!$A$2:$C$6. You can also start typing the formula, click across to the other sheet and select the range with your mouse. Excel writes the sheet reference for you.

Adding VAT to the result

Pieter's prices exclude VAT. To show the price including 15% VAT, multiply the whole lookup by 1.15:

=VLOOKUP(E2,$A$2:$C$6,3,FALSE)*1.15

For the blender that gives R1 033.85. You can wrap the formula in ROUND if you want whole rands: =ROUND(VLOOKUP(E2,$A$2:$C$6,3,FALSE)*1.15,0).

What VLOOKUP can't do

VLOOKUP has two limits worth knowing before they catch you:

Both problems have the same fix: a lookup that works with ranges instead of a column number. That's where XLOOKUP comes in.

XLOOKUP vs VLOOKUP

XLOOKUP is the newer lookup function. The same price lookup looks like this:

=XLOOKUP(E2,$A$2:$A$6,$C$2:$C$6,"Not found")

You give it three things: what to find, the column to search in, and the column to return. There's no column number to count. The fourth part is optional text to show when the code isn't there, so you get "Not found" instead of #N/A.

Here's how they compare:

VLOOKUP XLOOKUP
Default match Approximate (TRUE) Exact
Can look left No Yes
Survives an inserted column No Yes
Built-in "not found" message No Yes
Works in Excel 2016 and 2019 Yes No

That last row is important. According to Microsoft, XLOOKUP is available in Excel for Microsoft 365, Excel 2021, Excel 2024 and Excel for the web. It is not available in Excel 2016 or Excel 2019. If you type it there, Excel doesn't recognise the function and shows #NAME?.

Plenty of offices still run older versions, so it pays to know both. If your workbook will only ever be opened in a current version, use XLOOKUP. If you're sending it to a client or colleague who may be on Excel 2016, stick with VLOOKUP and FALSE.

A quick recap

Try it yourself

Reading a formula is one thing. Typing it and seeing the right price appear is what makes it stick.

In lesson 22, VLOOKUP (exact match), you build this kind of price lookup in a spreadsheet in your browser. Your answer is checked the moment you press Enter. Then move on to lesson 24, XLOOKUP and do the same job the newer way. Both are free, with no sign-up and nothing to install.

ExcelyourTraining is not affiliated with Microsoft. Excel is a trademark of Microsoft Corporation.