VLookup Tutorial
VLookup Tutorial
VLOOKUP is one of Excel’s most useful functions, and it’s also one of the least
understood. In this article, we demystify VLOOKUP by way of a real-life example. We’ll
create a usable Invoice Template for a fictitious company.
So what is VLOOKUP? Well, of course it’s an Excel function. This article will assume that
the reader already has a passing understanding of Excel functions, and can use basic
functions such as SUM, AVERAGE, and TODAY. In its most common usage, VLOOKUP is
a database function, meaning that it works with database tables – or more simply, lists of
things in an Excel worksheet. What sort of things? Well, any sort of thing. You may have
a worksheet that contains a list of employees, or products, or customers, or CDs in your CD
collection, or stars in the night sky. It doesn’t really matter.
Here’s an example of a list, or database. In this case it’s a list of products that our fictitious
company sells:
Usually lists like this have some sort of unique identifier for each item in the list. In this
case, the unique identifier is in the “Item Code” column. Note: For the VLOOKUP function
to work with a database/list, that list must have a column containing the unique identifier
(or “key”, or “ID”), andthat column must be the first column in the table. Our sample
database above satisfies this criterion.
The hardest part of using VLOOKUP is understanding exactly what it’s for. So let’s see if we
can get that clear first:
Put another way, if you put the VLOOKUP function into a cell and pass it one of the unique
identifiers from your database, it will return you one of the pieces of information associated
with that unique identifier. In the example above, you would pass VLOOKUP an item code,
and it would return to you either the corresponding item’s description, its price, or its
availability (its “In stock” quantity). Which of these pieces of information will it pass you
back? Well, you get to decide this when you’re creating the formula.
If all you need is one piece of information from the database, it would be a lot of trouble to
go to to construct a formula with a VLOOKUP function in it. Typically you would use this
sort of functionality in a reusable spreadsheet, such as a template. Each time someone
enters a valid item code, the system would retrieve all the necessary information about the
corresponding item.
Let’s create an example of this: An Invoice Template that we can reuse over and over in
our fictitious company.
This is how it’s going to work: The person using the invoice template will fill in a series of
item codes in column “A”, and the system will retrieve each item’s description and price,
which will be used to calculate the line total for each item (assuming we enter a valid
quantity).
For the purposes of keeping this example simple, we will locate the product database on a
separate sheet in the same workbook:
In reality, it’s more likely that the product database would be located in a separate
workbook. It makes little difference to the VLOOKUP function, which doesn’t really care if
the database is located on the same sheet, a different sheet, or a completely different
workbook.
After typing the data above, select the range A1:D7 and name it ProdData (no spaces,
remember to press Enter after typing the name).
Next, we move the active cell to the cell in which we want information retrieved from the
database by VLOOKUP to be stored. Interestingly, this is the step that most people get
wrong. To explain further: We are about to create a VLOOKUP formula that will retrieve
the description that corresponds to the item code in cell A11. Where do we want this
description put when we get it? In cell B11, of course. So that’s where we write the
VLOOKUP formula – in cell B11.
=vlookup(A11,ProdData,2,False)
Explanation
=vlookup(A11,ProdData,2,False)