How To Use The Excel VLOOKUP Function - Exceljet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Cart Login

Quick, clean, and to the point


Training
Videos
Functions
Formulas
Shortcuts
Blog

Search... Search

Skills Test First. CV Second. Open


Our Screening Tests Identify The Best Candidates And Make Your Hiring Decisions Bias-free. TestGorilla

Excel VLOOKUP Function

Summary 
VLOOKUP is an Excel function to look up data in a table organized vertically. VLOOKUP supports approximate and
exact matching, and wildcards (* ?) for partial matches. Lookup values must appear in the first column of the table
passed into VLOOKUP.
Purpose 
Lookup a value in a table by matching on the first column

Return value 
The matched value from a table.

Syntax 
=VLOOKUP (lookup_value, table_array, column_index_num, [range_lookup])

Arguments 
lookup_value - The value to look for in the first column of a table.
table_array - The table from which to retrieve a value.
column_index_num - The column in the table from which to retrieve a value.
range_lookup - [optional] TRUE = approximate match (default). FALSE = exact match.

Version 
Excel 2003

Usage notes 
VLOOKUP is an Excel function to get data from a table organized vertically. Lookup values must appear in the first
column of the table passed into VLOOKUP.  VLOOKUP supports approximate and exact matching, and wildcards (* ?) for
partial matches. 

Vertical data | Column Numbers | Only looks right | Matching Modes | Exact Match | Approximate Match | First
Match | Wildcard Match | Two-way Lookup | Multiple Criteria | #N/A Errors | Videos

Introduction

VLOOKUP is probably the most famous function in Excel, for reasons both good and bad. On the good side, VLOOKUP is
easy to use and does something very useful. For new users in particular, it is immensely satisfying to watch VLOOKUP
scan a table, find a match, and return a correct result. Using VLOOKUP successfully is a rite of passage: from beginner to
skilled Excel user.

On the bad side, VLOOKUP is limited and has dangerous defaults. Unlike INDEX and MATCH (or XLOOKUP), VLOOKUP
needs a complete table with lookup values in the first column. This makes it hard to use VLOOKUP with multiple
criteria. In addition, VLOOKUP's default matching behavior makes it easy to get incorrect results. Fear not. The key to
using VLOOKUP successfully is mastering the basics. Read on for a complete overview.

Arguments

VLOOKUP takes four arguments: lookup_value, table_array, column_index_num, and range_lookup. Lookup_value is the
value to look for, and table_array is the range of vertical data to look inside. The first column of table_array must contain
the lookup values to search. The column_index_num argument is the column number of the value to retrieve, where the
first column of table_array is column 1. Finally, range_lookup controls match behavior. If range_lookup is TRUE,
VLOOKUP will perform an approximate match. If range_lookup is FALSE, VLOOKUP will perform an exact match.
Important: range_lookup is optional and defaults to TRUE, so VLOOKUP will perform an approximate match by default.
See below for more information on matching.

V is for vertical

The purpose of VLOOKUP is to look up information in a table like this:

With the Order number in column B as the lookup_value, VLOOKUP can get the Cust. ID, Amount, Name, and State for
any order. For example, to get the name for order 1004, the formula is:

= VLOOKUP(1004,B5:F9,4,FALSE) // returns "Sue Martin"

To look up horizontal data, you can use HLOOKUP, INDEX and MATCH, or XLOOKUP.

VLOOKUP is based on column numbers

When you use VLOOKUP, imagine that every column in the table_array is numbered, starting from the left. To get a
value from a given column, provide the number for column_index_num. For example, the column index to retrieve the
first name below is 2:
By changing only column_index_num, you can look up columns 2, 3, and 4:

= VLOOKUP(H3,B4:E13,2,FALSE) // first name

= VLOOKUP(H3,B4:E13,3,FALSE) // last name

= VLOOKUP(H3,B4:E13,4,FALSE) // email address

Note: normally, we would use an absolute reference for H3 ($H$3) and B4:E13 ($B$4:$E$13) to prevent these from
changing when the formula is copied. Above, the references are relative to make them easier to read.

VLOOKUP only looks right

VLOOKUP can only look to the right. In other words, you can only retrieve data to the right of the column that holds
lookup values:

To lookup values to the left, see INDEX and MATCH, or XLOOKUP.

Match modes

VLOOKUP has two modes of matching, exact and approximate, controlled by the fourth argument, range_lookup. The
word "range" in this case refers to "range of values" – when range_lookup is TRUE, VLOOKUP will match a range of values
rather than an exact value. A good example of this is using VLOOKUP to calculate grades. When range_lookup is FALSE,
VLOOKUP performs an exact match, as in the example above.
Important:  range_lookup is optional defaults to TRUE. This means approximate match is the default mode, which can
be dangerous. Set range_lookup to FALSE to force exact matching:

= VLOOKUP(value,table,col_index) // approximate match (default)

= VLOOKUP(value,table,col_index,TRUE) // approximate match


= VLOOKUP(value,table,col_index,FALSE) // exact match

Tip: always supply a value for range_lookup as a reminder of expected behavior.

Note: You can also supply zero (0) for an exact match, and 1 for approximate match.

Exact match example

In most cases, you'll probably want to use VLOOKUP in exact match mode. This makes sense when you have a unique
key to use as a lookup value, for example, the movie title in this data:

The formula in H6 to find Year, based on an exact match of movie title, is:

= VLOOKUP(H4,B5:E9,2,FALSE) // FALSE = exact match

Video: How to use VLOOKUP for exact match

Approximate match example

When you want the best match, not necessarily an exact match, you'll want to use approximate mode. For example,
below we want to look up a commission rate in the table G5:H10. The lookup values come from column C. In this
example, we need to use VLOOKUP in approximate match mode, because in most cases an exact match will never be
found. The VLOOKUP formula in D5 is configured to perform an approximate match by setting the last argument to
TRUE:
= VLOOKUP(C5,$G$5:$H$10,2,TRUE) // TRUE = approximate match

VLOOKUP will scan values in column G for the lookup value. If an exact match is found, VLOOKUP will use it. If not,
VLOOKUP will "step back" and match the previous row. This means table_array must be sorted in ascending order by
lookup value to use approximate match.

Caution: If range_lookup is omitted or TRUE and table_array is not sorted by the first column in ascending order,
VLOOKUP may return incorrect or unexpected results.

Video: How to use VLOOKUP for approximate match

First match only

In the case of duplicate matching values, VLOOKUP will find the first match. In the screen below, VLOOKUP is
configured to find the price for the color "Green". There are three rows with the color Green, and VLOOKUP returns the
price in the first row, $17. The formula in cell F5 is:

= VLOOKUP(E5,B5:C11,2,FALSE) // returns 17
Tip: To retrieve multiple matches in a lookup operation, see the FILTER function.

Wildcard match

The VLOOKUP function supports wildcards, which makes it possible to perform a partial match on a lookup value. For
instance, you can use VLOOKUP to retrieve information from a table with a partial lookup_value and wildcard. To use
wildcards with VLOOKUP, you must use exact match mode by providing FALSE for range_lookup. In the screen below, the
formula in H7 retrieves the first name, "Michael", after typing "Aya" into cell H4. Notice the asterisk (*) wildcard is
concatenated to the lookup value inside the VLOOKUP formula:

= VLOOKUP($H$4,$B$5:$E$104,2,FALSE)

Read a more detailed explanation here.

Video: How to use VLOOKUP for wildcard matches.

Two-way lookup

Inside the VLOOKUP function, column_index_num is normally hard-coded as a static number.  However, you can also
create a dynamic column index by using the MATCH function to locate the needed column. This technique allows you to
create a dynamic two-way lookup, matching on both rows and columns. In the screen below, VLOOKUP is configured to
perform a lookup based on Name and Month. The formula in H6 is:

= VLOOKUP(H4,B5:E13,MATCH(H5,B4:E4,0),0)
For more details, see this example.

Video: Two-way match with VLOOKUP.

Note: In general, INDEX and MATCH is a more flexible way to perform two-way lookups.

Multiple criteria

The VLOOKUP function does not handle multiple criteria natively. However, you can use a helper column to join
multiple fields together, and use these fields like multiple criteria inside VLOOKUP.  In the example below, Column B is
a helper column that concatenates first and last names together with this formula:

= C5 & D5 // helper column

VLOOKUP is configured to do the same thing to create a lookup value. The formula in H6 is:

= VLOOKUP(H4 & H5,B5:E13,4,0)

For details, see this example. For a more advanced, flexible approach, see this example.
Note: INDEX and MATCH and XLOOKUP are better for lookups based on multiple criteria.

VLOOKUP and #N/A errors

If you use VLOOKUP you will inevitably run into the #N/A error. The #N/A error means "not found". For example, in the
screen below, the lookup value "Toy Story 2" does not exist in the lookup table, and all three VLOOKUP formulas return
#N/A:

The #N/A error is useful because tells you something is wrong. The reason for #N/A might be:

The lookup value does not exist in the table


The lookup value is misspelled, or contains extra space
Match mode is exact, but should be approximate
The table range is not entered correctly
You are copying VLOOKUP, and the table reference is not locked

To "trap" the NA error and return a different value, you can use the IFNA function like this:

The formula in H6 is:

= IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"Not found")

The message can be customized as desired. To return nothing (i.e. to display a blank result) when VLOOKUP returns
#N/A you can use an empty string ("") like this:
= IFNA(VLOOKUP(H4,B5:E9,2,FALSE),"") // no message

You can also use the IFERROR function to trap VLOOKUP #N/A errors. However, be careful with IFERROR, because it
will catch any error, not just the #N/A error.

Read more: VLOOKUP without #N/A errors 

Video: What to do when VLOOKUP returns #N/A

More about VLOOKUP

More VLOOKUP examples


VLOOKUP videos
23 tips for using VLOOKUP

Other notes

VLOOKUP performs an approximate match by default.


VLOOKUP is not case-sensitive.
Range_lookup controls the match mode. FALSE = exact, TRUE = approximate (default).
If range_lookup is omitted or TRUE or 1: 

VLOOKUP will match the nearest value less than the lookup_value.


VLOOKUP will still use an exact match if one exists.
The column 1 of table_array must be sorted in ascending order.

If range_lookup is FALSE or zero:

VLOOKUP performs an exact match.


Column 1 of table_array does not need to be sorted.

VLOOKUP formula examples

Merge tables with VLOOKUP


This is a standard "exact match" VLOOKUP formula with one exception: the column
index is calculated using the COLUMN function. When the COLUMN function is used
without any arguments, it returns a number that...
Multiple chained VLOOKUPs
The IFERROR function is designed to trap errors and perform an alternate action when
an error is detected. The VLOOKUP function will throw an #N/A error when a value isn't
found.
By nesting multiple VLOOKUPs inside...

Map inputs to arbitrary values


This formula uses the value in cell F6 for a lookup value, the range B5:C10 for the
lookup table, 2 to indicate "2nd column", and zero as the last argument to force an exact
match.
Although in this case we are mapping...

Basic Tax Rate calculation with VLOOKUP


VLOOKUP requires lookup values to be in the first column of the lookup table. Because
the first column in the example is actually "Band", we are purposely excluding this
column from the table range provided to VLOOKUP,...

Simple currency conversion


The formula in this example converts amounts in USD to other currencies using
currency codes. Available currencies and exact conversion rates can be adjusted by
editing the values in the table on the right.
The core...

Partial match with VLOOKUP


In this example, the goal is to retrieve employee information from a table using only a
partial match on the last name. In other words, by typing "Aya" into cell H4, the formula
should retrieve information about Michael...

Calculate grades with VLOOKUP


In this example, the scores in column F are lookup values for the VLOOKUP function.
The lookup table is the named range "key" (B5:C9). The column index is provided as 2,
since we want VLOOKUP to return a grade from the...

VLOOKUP with two client rates


This formula is composed of two lookups for the same client. The first lookup finds the
onsite rate for the client in column B and multiplies the result by the number of hours
in column C:
=VLOOKUP(B5,rates,2,0)*C5...
VLOOKUP with multiple criteria advanced
In this example, the goal is to use VLOOKUP to retrieve the price for a given item based
on three criteria: name, size, and color, which are entered in H5:H7. For example, for a
Blue Medium T-shirt, VLOOKUP should...

Due date by category


In this example, the goal is to create a due date based on category, where each category
has a different number of days allocated to complete a given task, issue, project, etc.
The amount of time available to resolve ...

Self-contained VLOOKUP
The goal in this example is to create a self-contained lookup formula to assign a grade
to the score in cell E7, based on the table in B6:C10. However, instead of providing
B6:B10 as a reference for the table_array...

VLOOKUP from another sheet


In this example, we have a table of employee locations like this on Sheet2:
On Sheet1,
we retrieve the building location for each team member using this formula:
=VLOOKUP(B5,Sheet2!$B$5:$C$104,2,0)
The lookup...

VLOOKUP with variable table array


In this example, the goal is to set up VLOOKUP to retrieve costs based on a variable
vendor name. In other words, we want a formula that allows us to switch tables
dynamically based on a user-supplied value. There are...

VLOOKUP with numbers and text


In this example, the goal is to configure VLOOKUP to perform a lookup in a table where
the first column contains numbers entered as text, and the lookup value is a true
number. This mismatch between numbers and text...

Make words plural


In this example, the goal is to make a noun plural when the number of items is greater
than one. In many cases, a noun can be made plural by adding an "s". However, many
nouns have an irregular plural form, and the main...
Related videos

How to use VLOOKUP for approximate matches


In this video we look at how to configure VLOOKUP to look up values based on an
approximate match. This is good for tax rates, postage, commissions, and the like.

How to group values with VLOOKUP


In this video we'll look at a simple way to use VLOOKUP to group data into specific
categories.

How to use the CHOOSE function


In this video we'll look at how you can use the CHOOSE function. We also compare a
formula based on CHOOSE vs. a formula based on VLOOKUP.

How to select arguments with the formula tip window


In this video we'll look at the best way to select function arguments in a formula: the
function screen tip window.

How to troubleshoot VLOOKUP approximate match


In this video we'll look at how to troubleshoot a VLOOKUP formula designed to perform
an approximate match.

How to use VLOOKUP to merge tables


This video shows how to use VLOOKUP to merge data in two tables based on a common
ID. You can even use this technique to reorder the columns you retrieve.

Related functions 
Excel HLOOKUP Function
The Excel HLOOKUP function finds and retrieve a value from data in a horizontal table.
The "H" in HLOOKUP stands for "horizontal", and lookup values must appear in the first
row of the table, moving horizontally to the right. HLOOKUP supports...

Excel LOOKUP Function


The Excel LOOKUP function performs an approximate match lookup in a one-column or
one-row range, and returns the corresponding value from another one-column or one-
row range. LOOKUP's default behavior makes it useful for solving certain problems...

Excel INDEX Function


The Excel INDEX function returns the value at a given location in a range or array. You
can use INDEX to retrieve individual values, or entire rows and columns. The MATCH
function is often used together with INDEX to provide row and column...

Excel MATCH Function


MATCH is an Excel function used to locate the position of a lookup value in a row,
column, or table. MATCH supports approximate and exact matching, and wildcards (* ?)
for partial matches. Often, MATCH is combined...

Excel XLOOKUP Function


The Excel XLOOKUP function is a modern and flexible replacement for older functions
like VLOOKUP, HLOOKUP, and LOOKUP.  XLOOKUP supports approximate and exact
matching, wildcards (* ?) for partial matches, and lookups in vertical or horizontal...

Excel XMATCH Function


The Excel XMATCH function performs a lookup and returns a position in vertical or
horizontal ranges. It is a more robust and flexible successor to the MATCH function.
XMATCH supports approximate and exact matching, reverse search, and wildcards...

Excel FILTER Function


The Excel FILTER function filters a range of data based on supplied criteria, and extracts
matching records.

See also 
23 things you should know about VLOOKUP
Danger: beware VLOOKUP defaults
500 Formulas | 101 Functions

Download 100+ Important Excel Functions


Get over 100 Excel Functions you should know in one handy PDF.

email address Get the PDF

JOBSTREET PH

Your Hiring

is On Us.
Use your FREE Lite Ads

before they’re gone!

Claim on JobStreet

today.

Sign Up

Topics

Formula Basics
Formula Examples
Dynamic Array Formulas
Conditional Formatting
Pivot Tables
Excel Tables
Shortcuts
More...

Key functions
IF function
VLOOKUP function
XLOOKUP function
FILTER function
SUMIFS function
COUNTIFS function
SUMPRODUCT function
INDEX and MATCH
More functions...

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you
work faster in Excel. We create short videos, and clear examples of formulas,
functions, pivot tables, conditional formatting, and charts. Read more.
Really great and very useful. Thanks for sharing -Arul

Excel video training


Quick, clean, and to the point.

Learn more

Home
About
Blog
Contact
Feedback
© 2012-2022 Exceljet. Terms of use

You might also like