You are on page 1of 26

VLOOKUP and INDEX-MATCH Examples

https://www.vertex42.com/blog/excel-formulas/vlookup-and-index-match-examples.html

This workbook contains examples from the article "VLOOKUP and INDEX-MATCH Examples in Excel." Regar
sharing, think of this file like a book. You may use the ideas and techniques and formulas explained here, but y
reproduce this worksheet or copy substantial portions from it, just as you would not do so with a book. Thank y

Bookmarks: A Simple VLOOKUP and INDEX-MATCH Example


Syntax for MATCH and INDEX
Using Wilcard Characters for Partial Matches
Return Approximate Matches (for Grades, Discounts and Tax Brackets)
2D Lookups using VLOOKUP and INDEX-MATCH
3D Lookups using INDEX-MATCH and VLOOKUP
Case-Sensitive EXACT Lookup using INDEX-MATCH
Multiple-Criteria Matches using VLOOKUP and INDEX-MATCH
Multiple Non-Exact Criteria Lookups using INDEX-MATCH
Find the Last Numeric Value in a Column
Find the Last Text Value in a Column
Return the Last Non-BLANK Value
Return the Last Non-Empty Value Using LOOKUP
Return the nth Match using INDEX

EXAMPLES

A Simple VLOOKUP and INDEX-MATCH Example


In this example, we are looking for the text "a_003" within the Item ID column and want to return the correspon
Price column.

Price List Table VLOOKUP Example


Item ID Item Name Price Lookup Value
A_001 Product A 34.50 a_003
A_002 Product B 52.30
A_003 Product C 29.30 INDEX-MATCH Example
A_004 Product D 87.20 Lookup Value
A_005 Product E 98.10 a_003

VLOOKUP Syntax

Formula: =VLOOKUP(lookup_value, table_array, 3, FALSE)

NOTES If you insert a column into the table, the hard-coded "3" may no longer point to the correct colu
from happening, use (COLUMN(result_column)-COLUMN(lookup_column)+1) in place of the 3

INDEX-MATCH Syntax

Formula: =INDEX( result_range,MATCH(lookup_value,lookup_range,0) )

NOTE For an exact match, the last argument in the VLOOKUP and MATCH functions should be FAL
Actually, the lookup is not truly "exact" because VLOOKUP and MATCH are not case-sensitive
the option an "exact match" so we'll go with that and explain how to do a case-sensitive match

General Remarks about VLOOKUP and INDEX-MATCH

NOTES Remember to use FALSE or 0 for exact matches, because both VLOOKUP and MATCH defau
or 1.

As a general rule, use absolute ($A$1) cell references to refer to the lookup ranges, table arra
when you copy the lookup formula you will usually want those ranges to not change.

Check for extra blank spaces if you think a lookup formula should be finding a match, but it is
as text may result in a match error, also.

Use IFERROR to handle the error returned when an exact match is not found.

TEMPLATE See it in action: Purchase Order with Price List

TEMPLATE See it in action: Food Diary Template

Syntax for MATCH and INDEX


The INDEX-MATCH formula is an example of a simple nested function where we use the result from the MATC
the arguments for the INDEX function. The example below shows this being done in two separate steps.
State List Step 1: Find the Row Number N
State Abbr Population Name Lookup Value
CA 38.33M California MT
NV 2.79M Nevada
MT 1.02M Montana Step 2: Return the Value on Row N
TX 26.45M Texas Row Number
NY 19.65M New York 3

Step 1: MATCH returns the position number of the matched value within th

Syntax: =MATCH(lookup_value,lookup_range,[match_type])

Example: =MATCH("MT",{"CA","NV","MT","TX","NY"},0)

NOTE The lookup_range can be a row or column, but if lookup_range is more than one row or colum
an error.

The match_type is optional, but the default is not 0. So, it is is best to always specify the matc

Step 2: INDEX returns the value from an array based on the row and colum

Syntax: =INDEX(array,row_number,[column_number],[area_number])

NOTES You don't need to include the column_number if the array is a single column.

The area_number argument is only for 3D arrays.

Formula: =INDEX(array,row_number)

Formula: =INDEX(array,row_number,column_number)

Wildcard Characters (?, *) for Partial Matches Using VLOOKUP and


Product Price lookup_value

A5B_199 $ 10.00 Example 1: *200


A6B_200 $ 20.00 Example 2: A?C*
A2C_201 $ 30.00 Example 3: *~?*
A?C_202 $ 40.00
A4C_203 $ 50.00

Example 1: * (asterisk) matches any number of characters.

In this example, we are looking for the first occurrence of a text string ending with "200"

Example 2: ? (question mark) matches any single character.

In this example, we are looking for the first product that starts with an "A" and has "C" as the 3

Example 3: Use ~ (tilde) in front of a wildcard character to treat it as a literal

In this example, we are looking for the first occurrence of any product name containing a ques

Return Approximate Matches Using VLOOKUP and INDEX-MATCH


The following examples show how to use VLOOKUP and INDEX-MATCH to return values that are not necessa
Important: When using an "Approximate Match" with VLOOKUP (where the 4th argument = TRUE) and a "Les
MATCH (where the 3rd argument = 1), the lookup range needs to be sorted in ascending order.

Formula: =VLOOKUP(lookup_value,table_array,result_column_num,TRUE)

Formula: =INDEX(result_range,MATCH(lookup_value,lookup_range,1)

Example 1: Grade Lookup

Grade Table Lookup Formula Examples


Percentage Grade percent VLOOKUP

0% F 93% A
60% D 70% C
70% C 75% C
80% B 83% B
90% A

TEMPLATE See it in action: Gradebook Template

Example 2: Return a Discount Rate Based on Quantity

Discount Table Lookup Formula Examples


Quantity Discount quantity VLOOKUP

0 0% 100 2%
10 1% 5 0%
100 2% 125 2%
1000 5% 2500 5%

Example 3: Tax Bracket Lookup

Tax Table Lookup Formula Examples


Excess Over Percent lookup_value VLOOKUP

0.00 0.0% 50000 15%


8,650.00 10.0% 25000 10%
27,300.00 15.0% 100 0%
84,550.00 25.0%
161,750.00 28.0%

ARTICLE See it in action: Paycheck Calculator Template

Example 4: Experiment with what happens when the data is not sorted.

Discount Table Lookup Formula Examples


Quantity Discount quantity VLOOKUP

0 0% 200 5%
150 1%
300 2%
0 3%
0 4%
50 5%
500 6%
0 7%
1000 8%

NOTE For these types of matches, the formulas use an efficient search algorithm that assumes the d
ascending order. That is why the above example returns 5% instead of 1% (a sequential chec
first cell) or 7% (a sequential check starting with the last cell). The algorithm looks at the first a
looks at the middle value (which is zero) and decides to limit its search to the last 5 rows, then
500 and decides to limit the search to rows 5-7, etc.

2D Lookups From a Data Table Using VLOOKUP and INDEX-MATC


In this example, we'll do a mileage lookup between two cities. This is basically the same as the simple lookup f
the VLOOKUP formula, we replace the col_index_num argument with a MATCH function and in the INDEX for
column_number argument with a MATCH function.

From: Phoenix Mileage Phoenix


To: Denver Phoenix 0
Albuquerque 422
VLOOKUP-MATCH: 822 Denver 822
INDEX-MATCH-MATCH: 822 New York 2406
HLOOKUP-MATCH: 822

Example 1: Using VLOOKUP-MATCH

Formula: =VLOOKUP(row_lookup_value,table_array,
MATCH(column_lookup_value,column_label_range,0), FALSE)

Example 2: Using INDEX-MATCH-MATCH

Formula: =INDEX( result_array, MATCH(row_lookup_value,row_label_range,0),


MATCH(column_lookup_value,column_label_range,0) )
Example 3: Using HLOOKUP-MATCH

Formula: =HLOOKUP(column_lookup_value,table_array,
MATCH(row_lookup_value,row_label_range,0), FALSE)

3D Lookups Using INDEX-MATCH-MATCH-MATCH


In this example, we'll do a mileage lookup between two cities with a 3rd option being by road or by plane. The
allows you to return a value from a 3D array. You can replace the row_number, column_number, and area_nu
formula or cell reference. When using a 3D lookup, the reference for the INDEX function should be multiple sa
surrounded by parentheses like this: (A:A,C:C), or you can use a named range.

Syntax: =INDEX(array,row_number,column_number,area_number)

Formula: =INDEX( (array_range1,array_range2) ,


MATCH(row_lookup_value,row_label_range,0),
MATCH(column_lookup_value,column_label_range,0),
MATCH(table_name, {"Road","Plane"}, 0) )

From: Phoenix Road Phoenix


To: Albuquerque Phoenix 0
By: Road Albuquerque 422
Denver 822
INDEX-MATCH: 422 New York 2406

VLOOKUP: 422 Plane Phoenix


Phoenix 0
Albuquerque 329
Denver 597
New York 2150

3D Lookups Using VLOOKUP

You can also do 3D lookups using VLOOKUP. Starting with the 2D lookup formula, we just need a formula to r
table_array argument. In this example we'll use the CHOOSE function and define the syntax for this example b
MATCH to return the table_number based on the chosen value of "Road" or "Plane".
CHOOSE: =CHOOSE(table_number,table_array_1,table_array_2,...)

Formula: =VLOOKUP(row_lookup_value, CHOOSE( MATCH(table_name,


{"Road","Plane"},0), road_table, plane_table),
MATCH(column_lookup_value,column_label_range,0), FALSE)

Case-Sensitive EXACT Lookup Using INDEX-MATCH


Most lookups and logical comparisons in Excel, such as A1=B1 are NOT case-sensitive, meaning that "A"="a"
EXACT(value1,value2) function allows you to make a comparison between value1 and value2 that IS case sen
handle numbers, so EXACT("A","a") returns FALSE and EXACT("B","B") returns TRUE. If you compare a valu
EXACT("B",A1:A20) then the function returns an array of TRUE and FALSE values. This allows us to make a v
the INDEX-MATCH formula and we just need to press Ctrl+Shift+Enter because the formula will be an Array F

Formula: =INDEX(price_list, MATCH(TRUE, Array Formula: Remember to press


EXACT(lookup_product,product_list),0) )

Price List Table Case-Sensitive Lookup


Product Price lookup
A_001 10.00 Example 1: a_001
a_001 20.00 Example 2: b_003
B_003 30.00
b_003 40.00

VLOOKUP and INDEX-MATCH Using Multiple Match Criteria


One way to do an exact-match using multiple criteria is to concatenate the results from the lookup columns. Us
requires using a helper column containing the concatenated lookup columns. INDEX-MATCH does not need th
it becomes an array formula (Ctrl+Shift+Enter).

Formula: =VLOOKUP( value_1 & value_2, table_array, col_index_num, FALSE)

Formula: =INDEX(result_range,MATCH(value1&value2,lookup_col1&lookup_col2,0))
Helper Product Color Price Qty
Ablue A blue 34.50 34
Agreen A green 52.30 28 Lookup Value:
Bblue B blue 29.30 57
Bgreen B green 87.20 103
Byellow B yellow 98.10 23 INDEX-MATCH:

Lookups with Multiple Non-Exact Criteria using INDEX-MATCH


When you want to use logical conditions such as A > B or A = B in your lookup, a simple method is to use IND
convert the lookup_range to TRUE/FALSE and search for the first occurrence of TRUE. Using this method, yo
number of conditions. The formula must be entered as an array formula (Ctrl+Shift+Enter).

Formula: =INDEX( result_range, MATCH(1, (lookup_col1>lookup_value1) *


(lookup_col2<lookup_value2) ,0) )

Product Price Qty Price > 40


A 34.50 34 Qty < 40
B 52.30 28
C 29.30 57 Result: B
D 87.20 103
E 98.10 23

Find the Last Numeric Value in a Column


When using an approximate lookup for VLOOKUP and MATCH, you can return the last numeric value in a colu
extremely large number as the lookup value. A common example would be to return the last value in a Balance
account register. If the lookup_column contains text, it will be ignored.

Formula: =VLOOKUP( 9E+99, lookup_column, 1, TRUE)

Formula: =INDEX( lookup_column, MATCH( 9E+99, lookup_column, 1) )

Formula: =LOOKUP( 42, 1 / ISNUMBER(lookup_range), result_range)

Amount Balance
300.00 300.00 VLOOKUP 60
(240.00) 60.00
text INDEX-MATCH 60

#N/A LOOKUP 60

TEMPLATE See it in action: Checkbook Register Template

Find the Last Text Value in a Column


When searching for the last text value, instead of a large numeric value as in the previous example, we use a "
that, I mean a text value that would show up last if you sorted a column in alphabetical order. If you are using t
without special characters, that could be "zzzzzz" but if you are using Greek characters or symbols in your list,
Unicode Character such as 🗿 as the lookup value.

Formula: =VLOOKUP( "🗿", lookup_column, 1, TRUE)

Formula: =INDEX( lookup_column, MATCH( "🗿", lookup_column, 1) )

Formula: =LOOKUP( 42, 1 / ISTEXT(lookup_range), result_range)

Text
alpha VLOOKUP Ω
to
Ω INDEX-MATCH Ω
5000
#N/A LOOKUP Ω

Note: Using MATCH("*",lookup_column,-1) won't always find the last text value. Text beginning with symbols l
leading space will make that formula not find the last text value.

SEE ALSO Using Unicode Characters in Excel

Return the Last Non-BLANK Value


If your column contains both text and numeric values, you may want a formula to return the last non-blank valu
MATCH formula, we can search for the last numeric value and the last text value and return whichever comes

Formula: =INDEX( lookup_range, MAX( MATCH( "🗿", lookup_range, 1), MATCH(9E+100,


lookup_range,1) ) )

A more concise formula uses the LOOKUP function. The LOOKUP function allows the lookup_range to be an e
than a direct reference (and it can be a row or column). We can use a logical comparison and search for the la
this:

Formula: =LOOKUP( 42, 1 / NOT(ISBLANK(lookup_range)), result_range)

The trick here is that the expression 1/NOT(ISBLANK(lookup_range)) returns an array of 1s for TRUE and #DI
LOOKUP ignores the error values so it will return the last value in lookup_range that is not blank. The number
needs to be larger than 1 to return the last non-blank value in the range.

Text
1 LOOKUP 32
#N/A
32 INDEX-MATCH 32

Return the Last Non-EMPTY Value Using LOOKUP


If you are using a formula to return an empty value "" and you want to ignore those cells when searching for th
range, you can use the LOOKUP function with the expression 1/(lookup_range<>"").

Text LOOKUP abc


1
#N/A POSITION 4
abc
=""

Formula: =LOOKUP( 42, 1 / (lookup_range<>""), lookup_range)


Return the relative row number instead.

Formula: =LOOKUP( 42, 1 / (lookup_range<>""), ROW(lookup_range)-


ROW(first_cell_in_lookup_range)+1 )

Return the nth Match Using an Array Formula


ARTICLE Vertex42 Blog: Array Formula Examples

You can use the SMALL function to return the nth smallest value from an array, and we can use that along with
and the INDEX function to do a lookup based on the nth match. See the above reference to learn more about A
specifically the SMALL-IF formula.

Event Date
A 3/7/2018 DATE 3/7/2018
B 3/8/2018 OCCURRENCE 2
C 3/7/2018
D 3/7/2018 EVENT C
E 3/10/2018

Return the 2nd Event occurring on the date 3/7/2018. The { } brackets in the formula below are a reminder
Ctrl+Shift+Enter to enter the formula as an Array Formula. You don't actually type the brackets into the formula

Formula: { =INDEX(result_range,SMALL(IF(lookup_range=lookup_value,
ROW(lookup_range)-ROW(first_cell_in_lookup_range)+1),occurrence)) }

TEMPLATE See it in action: Daily Planner Template

REFERENCES

ARTICLE support.office.com: MATCH function

ARTICLE support.office.com: VLOOKUP function


ARTICLE support.office.com: INDEX function

ARTICLE exceljet.net: "23 things you should know about vlookup"


mples.html © 2017 Vertex42 LLC

ATCH Examples in Excel." Regarding copyright and


and formulas explained here, but you may not
uld not do so with a book. Thank you. - Jon Wittwer

n and want to return the corresponding value from the

OOKUP Example
Result
29.30

EX-MATCH Example
Result
29.30

no longer point to the correct column. To prevent that


ookup_column)+1) in place of the 3 in this example.

MATCH functions should be FALSE or the value 0.


and MATCH are not case-sensitive, but the syntax calls
how to do a case-sensitive match later.

both VLOOKUP and MATCH default to a value of TRUE

er to the lookup ranges, table arrays, etc. because


e ranges to not change.

hould be finding a match, but it is not. Numbers stored

match is not found.

e we use the result from the MATCH function as one of


done in two separate steps.
p 1: Find the Row Number N
Row Number
3 =MATCH("MT",lookup_range,0)

p 2: Return the Value on Row N


Result
Montana =INDEX(result_range,3)

matched value within the lookup range

State Abbr Row


MT 3

ge is more than one row or column, MATCH will return

is best to always specify the match type.

d on the row and column number

a single column.

Row Population Name


3 1.02M Montana

Row Column Result


3 2 1.02M
1 3 California

Using VLOOKUP and INDEX-MATCH


VLOOKUP INDEX-MATCH

$ 20.00 $ 20.00
$ 30.00 $ 30.00
$ 40.00 $ 40.00

ext string ending with "200"

aracter.

s with an "A" and has "C" as the 3rd character.

ter to treat it as a literal character.

y product name containing a question mark.

P and INDEX-MATCH
return values that are not necessarily exact matches.
4th argument = TRUE) and a "Less than" match with
ed in ascending order.

Examples
INDEX-MATCH

A
C
C
B

Examples
INDEX-MATCH

2%
0%
2%
5%

Examples
INDEX-MATCH

15%
10%
0%

data is not sorted.

Examples
INDEX-MATCH

5%
arch algorithm that assumes the data is sorted in
instead of 1% (a sequential check starting with the
). The algorithm looks at the first and last value, then
its search to the last 5 rows, then looks at the value

UP and INDEX-MATCH-MATCH
y the same as the simple lookup formula, except that in
CH function and in the INDEX formula we replace the

Albuquerque Denver New York


422 822 2406
0 450 1989
450 0 1785
1989 1785 0
n being by road or by plane. The INDEX function
er, column_number, and area_number with a MATCH
EX function should be multiple same-size ranges
ge.

Albuquerque Denver New York


422 822 2406
0 450 1989
450 0 1785
1989 1785 0

Albuquerque Denver New York


329 597 2150
0 348 1827
348 0 1628
1827 1628 0

rmula, we just need a formula to replace the


efine the syntax for this example below. We'll use
"Plane".
MATCH
e-sensitive, meaning that "A"="a" and "B"="b". The
alue1 and value2 that IS case sensitive and it can also
urns TRUE. If you compare a value to a range like
values. This allows us to make a very small change to
use the formula will be an Array Formula.

rray Formula: Remember to press Ctrl+Shift+Enter

se-Sensitive Lookup
Result
20.00
40.00

Match Criteria
sults from the lookup columns. Using VLOOKUP
INDEX-MATCH does not need the helper column, but

m, FALSE)

lookup_col2,0))
Product: A
Color: green
Lookup Value: Agreen

VLOOKUP: 52.3
INDEX-MATCH: 52.3 Array Formula: Remember to press Ctrl+Shift+Enter

INDEX-MATCH
up, a simple method is to use INDEX-MATCH and
e of TRUE. Using this method, you can have any
+Shift+Enter).

ue1) *

Array Formula: Remember to press Ctrl+Shift+Enter

urn the last numeric value in a column if you use an


o return the last value in a Balance column for an

1) )

e)
the previous example, we use a "large" text value. By
phabetical order. If you are using the English alphabet
characters or symbols in your list, you could try a

ue. Text beginning with symbols like ! or $ or even a


la to return the last non-blank value. Using the INDEX-
alue and return whichever comes last.

1), MATCH(9E+100,

allows the lookup_range to be an expression rather


comparison and search for the last TRUE value like

ange)

s an array of 1s for TRUE and #DIV/0 errors for FALSE.


nge that is not blank. The number 42 is arbitrary - it just

those cells when searching for the last value in the


ge<>"").
)-

ay, and we can use that along with an array formula


ve reference to learn more about Array Formulas and

Ctrl+Shift+Enter

he formula below are a reminder to press


type the brackets into the formula.

lue,
ccurrence)) }
VLOOKUP and INDEX-MATCH Examples

By Vertex42.com
https://www.vertex42.com/blog/excel-formulas/vlookup-and-index-match-examples.html

© 2017 Vertex42 LLC

This spreadsheet, including all worksheets and associated content is a


copyrighted work under the United States and other copyright laws.

Do not submit copies or modifications of this file to any website or online


template gallery.

Please review the following license agreement to learn how you may or
may not use this file. Thank you.

https://www.vertex42.com/licensing/EULA_privateuse.html

You might also like