How to Do VLOOKUP in Excel

Spreadsheets are known for having many formulas and functions. One that continually fascinates users is the VLOOKUP formula because of its ability to link to other data columns. While Microsoft provides helpful information, including VLOOKUP syntax, sometimes it’s best to learn by example. This Excel VLOOKUP tutorial provides two examples using different approximate match and exact match types. (Includes Excel spreadsheet examples.)

info icon — If you’re using Google Sheets, please see Using Google Sheets & VLOOKUP.

When I first heard about this powerful Excel function in 2005, I took a look at the help file and syntax. I then rolled my eyes.

VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup])

It looked too difficult, and I couldn’t see the immediate benefit. But sometimes, pushing through difficulties can make things easier in the long run.

When it comes to learning Microsoft Excel formulas and functions, I like to start with an easy example. This VLOOKUP tutorial will provide two examples using different arguments and lookup values.

What is Excel VLOOKUP Function?

VLOOKUP is an Excel function that allows you to search and retrieve a cell’s content from one column and use it in another location to retrieve data. As you might guess, the “V” stands for vertical and relies on looking up data from the leftmost column of a lookup table.

This lookup column could be on the same worksheet you’re viewing or another within your workbook. The function requires a common field or key and four arguments. The function allows you to specify whether to use an exact match or an approximate match.

Let’s put these terms in context and give a real example of where and how they might be used. When I do website analysis, I use several tools. I export data from each service into a .CSV file or Excel .XLSX file. Each tool has its own file that I use to create a sheet within a workbook.

The problem is I have five worksheets in this workbook. I don’t want to be switching between each sheet because that’s not efficient. Moreover, I want to do some of my own calculations using other Excel formulas.

The solution is to find a common denominator or key between these worksheets. In this case, all the data files from my analysis tools have a field for the page URL. Using this common key, I can create a new spreadsheet and pull only the needed columns from each tool using the VLOOKUP function. Excel does all the heavy lifting. This allows me to concentrate on one worksheet with just the data I need.

VLOOKUP Example 1 – Approximate Match

Periodically, I’ve volunteered to work on local elections. I often get assigned the data analysis of the voter registration file. These files are massive.

One cell reference contains the voter’s birth date. However, I didn’t want the voter’s birth date to show on the final distributed files. But, I did want to do some age analysis.

Instead, I decided to create a segment based on age ranges and a lookup formula. Excel would do a vertical lookup that returns the matching value from one column to the desired cell. Rather than showing a voter was 28, I would define them as “Young.”

VLOOKUP example with lookup table on same sheet.
Using VLOOKUP to determine Age Segments

Let’s refer to the screenshot above with my first fictitious voter, Sophia Collins. If you scan across to Column D (Age), you’ll see she is 39 years old and in the “Mature” segment. The value of “Mature” in Column E was dynamically pulled in using Excel’s VLOOKUP function.

The small table in columns H and I with blue headings is the lookup table. Microsoft refers to this as a table_array. This is where I’ve defined my 4 age segments.

The way “Segment” works is if a voter is under 21, they are “New.” From 21-38, they are “Young.” From 39-59, they are “Mature.” And if they are 60 or older, they are “Senior.”

In Sophia’s case, Excel would take her age of 39 from cell D2 and return the closest match from Column H. Both these columns contain age data, which is our common key.

When Excel found a match, it would go to Column I and get the Label. The returned value was then copied to cell E2, the Segment. It might help to think of columns as being vertical. After all, this is a vertical lookup.

You might notice that the lookup table doesn’t list every age. It doesn’t have to because I’m using an approximate match. I’m telling Excel to find me the closest age.

For example, the next voter Evelyn Bennett is 51, but there is no value for 51 in Column H. In this case, 51 falls between 39 and 59, so she is also labeled “Mature.”

As we stated, to use the VLOOKUP function, there needs to be a common key. In this case, it’s age. Both columns D and H contain ages. The column headings and cell contents can be different and don’t have to be an exact match.

Understanding the Arguments

Let’s peel away some of the mystery and display how VLOOKUP shows in the Excel formula bar. In this illustration, I’ve clicked cell D2.

VLOOUP formula with callout annotations.
Showing VLOOKUP in the Formula bar

[A] – This represents the VLOOKUP formula for Cell D2

=VLOOKUP(D2,$H$2:I$5,2,TRUE)

[B] – Cell D2 is our first argument called Lookup_value.

[C] – The cell range $H2$2:$I$5 is our Table_array and the second argument.

[D] – 2 is the Col_index_num from our Table_array and the third argument. Label is the 2nd column.

[E] – TRUE is the Range_lookup and the fourth argument.

The good news is the VLOOKUP Function Arguments dialog guides you through these elements, so you don’t need to type the long string in Excel’s formula bar.

The term “argument” isn’t as complicated or negative as it sounds. If you’re familiar with the Excel formula bar, an argument is what goes in between the parentheses ( ). It provides an input value for the Excel function.

Some functions have required arguments, and others don’t need arguments. For example, to compute the voter’s age, I also used the TODAY function =TODAY(), which doesn’t use any arguments. Some common argument examples include:

  • cell range
  • true/false logical value
  • number

Using the formula from cell D2, here’s how these four arguments work.

VLOOKUP formula with numbered markers.

1. Lookup_value – Think of this field as your starting point. In this example, I want to look up Sophia’s Age from cell D2.

2. Table_array – This is the cell range for your lookup table. This range lookup can be on your existing worksheet or another worksheet. In this example, I have a small table with the age groupings and corresponding labels.

3. Col_index_num – This is a column number on your lookup table with the information you need. In our example, we want column 2, which has the column heading of Label. This will be our voter’s Segment name.

When we count, we’re counting the columns on the lookup table. Even though the “Label” column is Column I or the 9th column, it’s the 2nd column on the lookup table. Some people call this a Column Index.

4. Range-lookup – this field defines how close a match should exist between your Lookup_value (D2) and the value in the leftmost column on our lookup table. In our case, we want an approximate match, so we’ll use “TRUE.”

Table Array Rules & Caveats

There are several rules to remember about this table array.

  • Rule 1 – The left column must contain the values being referenced. Leftmost doesn’t mean it has to be in Column A. It’s just the leftmost or first column on the table_array. For example, on the lookup table above, the leftmost column is H.
  • Rule 2 – You can’t have duplicate values in the leftmost column of the lookup range. I couldn’t have two entries with the value “39”, with one being “Mature” and another “39” for “Go Getter.” Excel would complain.
  • Rule 3 – When referring to the lookup table, you want absolute cell references when you copy the VLOOKUP formula to other cells.

For example, if I want to use the same formula in cells E3 through E11, I don’t want my lookup cell references shifting each time I move down to the next cell. I need the cell references to be constant. This is called an absolute cell reference.

After you define your lookup range of cells, you can press F4. This will cycle through absolute and relative cell references. You want to select the option that includes a $ before your Column and Row. You can get around this if you know how to use Excel name ranges.

Using VLOOKUP in Our Formula

  1. Add in the column where you’ll enter the formula. In my case, I added Column E – Segment.
  2. Click cell E2.
  3. Click your Formulas tab from the top menu.
  4. Click the Insert Function button.
  5. From the Insert Function dialog, type “vlookup” in the Search for a function textbox. You may also select it from the Lookup & Reference category.
  6. Click Go.
Inserting vlookup function.
Finding the VLOOKUP function
  1. Click OK. The Function Arguments dialog will appear with text boxes for the required arguments.
Blank Function Arguments dialog.
VLOOKUP Required arguments
  1. In Lookup_value type D2. Or, you can click the cell.
  2. In Table_array type $H$2:$I$5. Note the $ signs.
  3. In Col_index_num type 2.
  4. In Range_lookup type true.
  5. Your Function Arguments dialog should look like the following. Notice in the lower left, you can see the Formula result.
Completed vlookup function arguments dialog.
Completed VLOOKUP Arguments
  1. Click OK. You should now see “Mature” in cell E2.
  2. Click cell E2.
  3. Click the small green square (fill handle) in the cell’s lower right corner to copy the VLOOKUP formula down the column.
Copying formula to other cells.
Click square to autofill cell

VLOOKUP Example 2 – Multiple Sheets & Exact Match

The second scenario dealt with that same election file. This time there was an extra worksheet for political parties. The voter’s party was listed as an alphanumeric value called “Pcode” and not the political party.

This coding wasn’t intuitive. For example, “D” was for the “American Independent Party,” but some thought it meant “Democratic Party.” Another difference was we needed an exact match for Party.

Pcode column requiring a lookup.
Non-intuitive column needing lookup value

Again, the way to solve this problem was to use the worksheet with the Pcode and translation and have Excel use the VLOOKUP function for the Party name. I could then add a column called “Political Party” to my original worksheet to show the lookup table’s information.

Using the Starting VLOOKUP Example File

  1. Download the starting Excel sample file. The file link is at the bottom of this tutorial.
  2. Review Example 2 – Voters worksheet. It has voter first and last names, but only a PCODE.
  3. Review Example 2 -Party Codes worksheet. It has a listing of party codes and political names. Each of the Party Codes and Names are unique. You’ll also note that Column A is sorted in ascending order.
Excel worksheet with vlookup values.
Worksheet with Translated Code Names
  1. Add your new column on the Voters worksheet that will display the info pulled from the Lookup table on the Party Codes worksheet. In my example, I added a column called Political Party in Column D. This is where I will insert the Excel function.
New Excel column for lookup values.
Add a new Excel column for lookup values
  1. Place your cursor in the first blank cell in that column. In my example, this is cell D2.
  2. Follow Steps 3-7 from Example 1.

Defining the Argument Values

After you click OK, Excel’s Function Arguments dialog appears and allows you to define the four values. You’ll see that your starting cell and the formula bar show the beginning part of the function =VLOOKUP(). The Function Arguments dialog adds the needed data elements that will display between ().

For illustration purposes, I have overlaid the Party Codes worksheet on top to show the relationships.

Mapping the VLOOKUP Function Arguments.
Mapping the VLOOKUP Function Arguments

After entering the required arguments, my dialog looks like the example below.

Mapped Values from both worksheets.
Mapped Values from Both Worksheets

You can see in the red outlined formula bar above. I now have more information based on my entries in the Function Arguments dialog box. You might also note that when I clicked the Party Codes worksheet to add in my Table_array, Excel prepended the tab name before the cell range. However, I need to go back and enter my $ signs.

The other item of interest is that when you build these functions, Excel displays the result in the Formula result = text line. This is great feedback that can show if your function is on target. In our example, we can see Excel looked up the Pcode of “A” and returned the Political Party “Democratic.”

VLOOKUP is a powerful Excel function that can leverage spreadsheet data from other sources. There are many ways you can benefit from this function. In this example, I used a 1:1 code translation, but you could also use it for group assignments. For example, you could assign state codes to a region such as CT, VT, and MA to a “New England” region.

One important note about using Excel functions and formulas is you want to be careful when deleting columns. For example, in the final spreadsheet I distributed, I omitted the Age column. After completing my VLOOKUP and got my segments, I copied the cell values to a new Excel worksheet. If I had just deleted Column D, my Excel formula would’ve returned an error.

If you’re trying to do a horizontal lookup, you’ll be happy to learn that Excel has an HLOOKUP function. I haven’t done an HLOOKUP tutorial yet. If this interests you, let me know. However, Microsoft has released a new versatile lookup function called XLOOKUP.

Additional VLOOKUP Example Resources

Excel Formulas & Functions For Dummies
Bluttman, Ken (Author); English (Publication Language); 400 Pages - 11/06/2018 (Publication Date) - For Dummies (Publisher)
$20.19

Disclaimer: Images from Amazon Product Advertising API. I may receive an affiliate commission on these products if you buy. Updated: 2021-03-07