Vlookup with match in excel

Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010 More…Less

Tip: Try using the new XLOOKUP function, an improved version of VLOOKUP that works in any direction and returns exact matches by default, making it easier and more convenient to use than its predecessor.

Use VLOOKUP when you need to find things in a table or a range by row. For example, look up a price of an automotive part by the part number, or find an employee name based on their employee ID.

In its simplest form, the VLOOKUP function says:

=VLOOKUP(What you want to look up, where you want to look for it, the column number in the range containing the value to return, return an Approximate or Exact match – indicated as 1/TRUE, or 0/FALSE).

Your browser does not support video. Install Microsoft Silverlight, Adobe Flash Player, or Internet Explorer 9.

Tip: The secret to VLOOKUP is to organize your data so that the value you look up (Fruit) is to the left of the return value (Amount) you want to find.

Use the VLOOKUP function to look up a value in a table.

Syntax 

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

For example:

  • =VLOOKUP(A2,A10:C20,2,TRUE)

  • =VLOOKUP(«Fontana»,B2:E7,2,FALSE)

  • =VLOOKUP(A2,’Client Details’!A:F,3,FALSE)

Argument name

Description

lookup_value    (required)

The value you want to look up. The value you want to look up must be in the first column of the range of cells you specify in the table_array argument.

For example, if table-array spans cells B2:D7, then your lookup_value must be in column B.


Lookup_value
can be a value or a reference to a cell.

table_array    (required)

The range of cells in which the VLOOKUP will search for the lookup_value and the return value. You can use a named range or a table, and you can use names in the argument instead of cell references. 

The first column in the cell range must contain the lookup_value. The cell range also needs to include the return value you want to find.

Learn how to select ranges in a worksheet.

col_index_num    (required)

The column number (starting with 1 for the left-most column of table_array) that contains the return value.

range_lookup   (optional)

A logical value that specifies whether you want VLOOKUP to find an approximate or an exact match:

  • Approximate match — 1/TRUE assumes the first column in the table is sorted either numerically or alphabetically, and will then search for the closest value. This is the default method if you don’t specify one. For example, =VLOOKUP(90,A1:B100,2,TRUE).

  • Exact match — 0/FALSE searches for the exact value in the first column. For example, =VLOOKUP(«Smith»,A1:B100,2,FALSE).

How to get started

There are four pieces of information that you will need in order to build the VLOOKUP syntax:

  1. The value you want to look up, also called the lookup value.

  2. The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.

  3. The column number in the range that contains the return value. For example, if you specify B2:D11 as the range, you should count B as the first column, C as the second, and so on.

  4. Optionally, you can specify TRUE if you want an approximate match or FALSE if you want an exact match of the return value. If you don’t specify anything, the default value will always be TRUE or approximate match.

Now put all of the above together as follows:

=VLOOKUP(lookup value, range containing the lookup value, the column number in the range containing the return value, Approximate match (TRUE) or Exact match (FALSE)).

Examples

Here are a few examples of VLOOKUP:

Example 1

=VLOOKUP (B3,B2:E7,2,FALSE)

VLOOKUP looks for Fontana in the first column (column B) in the table_array B2:E7, and returns Olivier from the second column (column C) of the table_array.  False returns an exact match.

Example 2

=VLOOKUP (102,A2:C7,2,FALSE)

VLOOKUP looks for an exact match (FALSE) of the last name for 102 (lookup_value) in the second column (column B) in the A2:C7 range, and returns Fontana.

Example 3

=IF(VLOOKUP(103,A1:E7,2,FALSE)="Souse","Located","Not found")

IF checks to see if VLOOKUP returns Sousa as the last name of employee correspoinding to 103 (lookup_value) in A1:E7 (table_array). Because the last name corresponding to 103 is Leal, the IF condition is false, and Not Found is displayed.

Example 4

=INT(YEARFRAC(DATE(2014,6,30),VLOOKUP(105,A2:E7,5,FLASE),1))



VLOOKUP looks for the birth date of the employee corresponding to 109 (lookup_value) in the A2:E7 range (table_array), and returns 03/04/1955. Then, YEARFRAC subtracts this birth date from 2014/6/30 and returns a value, which is then converted by INY to the integer 59.

Example 5

IF(ISNA(VLOOKUP(105,A2:E7,2,FLASE))=TRUE,"Employee not found",VLOOKUP(105,A2:E7,2,FALSE))



IF checks to see if VLOOKUP returns a value for last name from column B for 105 (lookup_value). If VLOOKUP finds a last name, then IF will display the last name, otherwise IF returns Employee not found. ISNA makes sure that if VLOOKUP returns #N/A, then the error is replaced by Employee not found, instead of #N/A.



In this example, the return value is Burke, which is the last name corresponding to 105.

You can use VLOOKUP to combine multiple tables into one, as long as one of the tables has fields in common with all the others. This can be especially useful if you need to share a workbook with people who have older versions of Excel that don’t support data features with multiple tables as data sources — by combining the sources into one table and changing the data feature’s data source to the new table, the data feature can be used in older Excel versions (provided the data feature itself is supported by the older version).

A worksheet with columns that use VLOOKUP to get data from other tables

Here, columns A-F and H have values or formulas that only use values on the worksheet, and the rest of the columns use VLOOKUP and the values of column A (Client Code) and column B (Attorney) to get data from other tables.

  1. Copy the table that has the common fields onto a new worksheet, and give it a name.

  2. Click Data > Data Tools > Relationships to open the Manage Relationships dialog box.

    The Manage Relationships dialog box

  3. For each listed relationship, note the following:

    • The field that links the tables (listed in parentheses in the dialog box). This is the lookup_value for your VLOOKUP formula.

    • The Related Lookup Table name. This is the table_array in your VLOOKUP formula.

    • The field (column) in the Related Lookup Table that has the data you want in your new column. This information is not shown in the Manage Relationships dialog — you’ll have to look at the Related Lookup Table to see which field you want to retrieve. You want to note the column number (A=1) — this is the col_index_num in your formula.

  4. To add a field to the new table, enter your VLOOKUP formula in the first empty column using the information you gathered in step 3.

    In our example, column G uses Attorney (the lookup_value) to get the Bill Rate data from the fourth column (col_index_num = 4) from the Attorneys worksheet table, tblAttorneys (the table_array), with the formula =VLOOKUP([@Attorney],tbl_Attorneys,4,FALSE).

    The formula could also use a cell reference and a range reference. In our example, it would be =VLOOKUP(A2,’Attorneys’!A:D,4,FALSE).

  5. Continue adding fields until you have all the fields that you need. If you are trying to prepare a workbook containing data features that use multiple tables, change the data source of the data feature to the new table.

Problem

What went wrong

Wrong value returned

If range_lookup is TRUE or left out, the first column needs to be sorted alphabetically or numerically. If the first column isn’t sorted, the return value might be something you don’t expect. Either sort the first column, or use FALSE for an exact match.

#N/A in cell

  • If range_lookup is TRUE, then if the value in the lookup_value is smaller than the smallest value in the first column of the table_array, you’ll get the #N/A error value.

  • If range_lookup is FALSE, the #N/A error value indicates that the exact number isn’t found.

For more information on resolving #N/A errors in VLOOKUP, see How to correct a #N/A error in the VLOOKUP function.

#REF! in cell

If col_index_num is greater than the number of columns in table-array, you’ll get the #REF! error value.

For more information on resolving #REF! errors in VLOOKUP, see How to correct a #REF! error.

#VALUE! in cell

If the table_array is less than 1, you’ll get the #VALUE! error value.

For more information on resolving #VALUE! errors in VLOOKUP, see How to correct a #VALUE! error in the VLOOKUP function.

#NAME? in cell

The #NAME? error value usually means that the formula is missing quotes. To look up a person’s name, make sure you use quotes around the name in the formula. For example, enter the name as «Fontana» in =VLOOKUP(«Fontana»,B2:E7,2,FALSE).

For more information, see How to correct a #NAME! error.

#SPILL! in cell

This particular #SPILL! error usually means that your formula is relying on implicit intersection for the lookup value, and using an entire column as a reference. For example, =VLOOKUP(A:A,A:C,2,FALSE). You can resolve the issue by anchoring the lookup reference with the @ operator like this: =VLOOKUP(@A:A,A:C,2,FALSE). Alternatively, you can use the traditional VLOOKUP method and refer to a single cell instead of an entire column: =VLOOKUP(A2,A:C,2,FALSE).

Do this

Why

Use absolute references for range_lookup

Using absolute references allows you to fill-down a formula so that it always looks at the same exact lookup range.

Learn how to use absolute cell references.

Don’t store number or date values as text.

When searching number or date values, be sure the data in the first column of table_array isn’t stored as text values. Otherwise, VLOOKUP might return an incorrect or unexpected value.

Sort the first column

Sort the first column of the table_array before using VLOOKUP when range_lookup is TRUE.

Use wildcard characters

If range_lookup is FALSE and lookup_value is text, you can use the wildcard characters—the question mark (?) and asterisk (*)—in lookup_value. A question mark matches any single character. An asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) in front of the character.

For example, =VLOOKUP(«Fontan?»,B2:E7,2,FALSE) will search for all instances of Fontana with a last letter that could vary.

Make sure your data doesn’t contain erroneous characters.

When searching text values in the first column, make sure the data in the first column doesn’t have leading spaces, trailing spaces, inconsistent use of straight ( ‘ or » ) and curly ( ‘ or “) quotation marks, or nonprinting characters. In these cases, VLOOKUP might return an unexpected value.

To get accurate results, try using the CLEAN function or the TRIM function to remove trailing spaces after table values in a cell.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Connect with an expert. Learn from live instructors.

See Also

XLOOKUP function

Video: When and how to use VLOOKUP

Quick Reference Card: VLOOKUP refresher

How to correct a #N/A error in the VLOOKUP function

Look up values with VLOOKUP, INDEX, or MATCH

HLOOKUP function

Need more help?

Tip: Try using the new XLOOKUP and XMATCH functions, improved versions of the functions described in this article. These new functions work in any direction and return exact matches by default, making them easier and more convenient to use than their predecessors.

Suppose that you have a list of office location numbers, and you need to know which employees are in each office. The spreadsheet is huge, so you might think it is challenging task. It’s actually quite easy to do with a lookup function.

The VLOOKUP and HLOOKUP functions, together with INDEX and MATCH, are some of the most useful functions in Excel.

Note: The Lookup Wizard feature is no longer available in Excel.

Here’s an example of how to use VLOOKUP.

=VLOOKUP(B2,C2:E7,3,TRUE)

In this example, B2 is the first argument—an element of data that the function needs to work. For VLOOKUP, this first argument is the value that you want to find. This argument can be a cell reference, or a fixed value such as «smith» or 21,000. The second argument is the range of cells, C2-:E7, in which to search for the value you want to find. The third argument is the column in that range of cells that contains the value that you seek.

The fourth argument is optional. Enter either TRUE or FALSE. If you enter TRUE, or leave the argument blank, the function returns an approximate match of the value you specify in the first argument. If you enter FALSE, the function will match the value provide by the first argument. In other words, leaving the fourth argument blank—or entering TRUE—gives you more flexibility.

This example shows you how the function works. When you enter a value in cell B2 (the first argument), VLOOKUP searches the cells in the range C2:E7 (2nd argument) and returns the closest approximate match from the third column in the range, column E (3rd argument).

A typical use of the VLOOKUP function

The fourth argument is empty, so the function returns an approximate match. If it didn’t, you’d have to enter one of the values in columns C or D to get a result at all.

When you’re comfortable with VLOOKUP, the HLOOKUP function is equally easy to use. You enter the same arguments, but it searches in rows instead of columns.

Using INDEX and MATCH instead of VLOOKUP

There are certain limitations with using VLOOKUP—the VLOOKUP function can only look up a value from left to right. This means that the column containing the value you look up should always be located to the left of the column containing the return value. Now if your spreadsheet isn’t built this way, then do not use VLOOKUP. Use the combination of INDEX and MATCH functions instead.

This example shows a small list where the value we want to search on, Chicago, isn’t in the leftmost column. So, we can’t use VLOOKUP. Instead, we’ll use the MATCH function to find Chicago in the range B1:B11. It’s found in row 4. Then, INDEX uses that value as the lookup argument, and finds the population for Chicago in the 4th column (column D). The formula used is shown in cell A14.

Using INDEX and MATCH to look up a value

For more examples of using INDEX and MATCH instead of VLOOKUP, see the article https://www.mrexcel.com/excel-tips/excel-vlookup-index-match/ by Bill Jelen, Microsoft MVP.

Give it a try

If you want to experiment with lookup functions before you try them out with your own data, here’s some sample data.

VLOOKUP Example at work

Copy the following data into a blank spreadsheet.

Tip: Before you paste the data into Excel, set the column widths for columns A through C to 250 pixels, and click Wrap Text (Home tab, Alignment group).

Density

Viscosity

Temperature

0.457

3.55

500

0.525

3.25

400

0.606

2.93

300

0.675

2.75

250

0.746

2.57

200

0.835

2.38

150

0.946

2.17

100

1.09

1.95

50

1.29

1.71

0

Formula

Description

Result

=VLOOKUP(1,A2:C10,2)

Using an approximate match, searches for the value 1 in column A, finds the largest value less than or equal to 1 in column A which is 0.946, and then returns the value from column B in the same row.

2.17

=VLOOKUP(1,A2:C10,3,TRUE)

Using an approximate match, searches for the value 1 in column A, finds the largest value less than or equal to 1 in column A, which is 0.946, and then returns the value from column C in the same row.

100

=VLOOKUP(0.7,A2:C10,3,FALSE)

Using an exact match, searches for the value 0.7 in column A. Because there is no exact match in column A, an error is returned.

#N/A

=VLOOKUP(0.1,A2:C10,2,TRUE)

Using an approximate match, searches for the value 0.1 in column A. Because 0.1 is less than the smallest value in column A, an error is returned.

#N/A

=VLOOKUP(2,A2:C10,2,TRUE)

Using an approximate match, searches for the value 2 in column A, finds the largest value less than or equal to 2 in column A, which is 1.29, and then returns the value from column B in the same row.

1.71

HLOOKUP Example

Copy all the cells in this table and paste it into cell A1 on a blank worksheet in Excel.

Tip: Before you paste the data into Excel, set the column widths for columns A through C to 250 pixels, and click Wrap Text (Home tab, Alignment group).

Axles

Bearings

Bolts

4

4

9

5

7

10

6

8

11

Formula

Description

Result

=HLOOKUP(«Axles», A1:C4, 2, TRUE)

Looks up «Axles» in row 1, and returns the value from row 2 that’s in the same column (column A).

4

=HLOOKUP(«Bearings», A1:C4, 3, FALSE)

Looks up «Bearings» in row 1, and returns the value from row 3 that’s in the same column (column B).

7

=HLOOKUP(«B», A1:C4, 3, TRUE)

Looks up «B» in row 1, and returns the value from row 3 that’s in the same column. Because an exact match for «B» is not found, the largest value in row 1 that is less than «B» is used: «Axles,» in column A.

5

=HLOOKUP(«Bolts», A1:C4, 4)

Looks up «Bolts» in row 1, and returns the value from row 4 that’s in the same column (column C).

11

=HLOOKUP(3, {1,2,3;»a»,»b»,»c»;»d»,»e»,»f»}, 2, TRUE)

Looks up the number 3 in the three-row array constant, and returns the value from row 2 in the same (in this case, third) column. There are three rows of values in the array constant, each row separated by a semicolon (;). Because «c» is found in row 2 and in the same column as 3, «c» is returned.

c

INDEX and MATCH Examples

This last example employs the INDEX and MATCH functions together to return the earliest invoice number and its corresponding date for each of five cities. Because the date is returned as a number, we use the TEXT function to format it as a date. The INDEX function actually uses the result of the MATCH function as its argument. The combination of the INDEX and MATCH functions are used twice in each formula – first, to return the invoice number, and then to return the date.

Copy all the cells in this table and paste it into cell A1 on a blank worksheet in Excel.

Tip: Before you paste the data into Excel, set the column widths for columns A through D to 250 pixels, and click Wrap Text (Home tab, Alignment group).

Invoice

City

Invoice Date

Earliest invoice by city, with date

3115

Atlanta

4/7/12

=»Atlanta = «&INDEX($A$2:$C$33,MATCH(«Atlanta»,$B$2:$B$33,0),1)& «, Invoice date: » & TEXT(INDEX($A$2:$C$33,MATCH(«Atlanta»,$B$2:$B$33,0),3),»m/d/yy»)

3137

Atlanta

4/9/12

=»Austin = «&INDEX($A$2:$C$33,MATCH(«Austin»,$B$2:$B$33,0),1)& «, Invoice date: » & TEXT(INDEX($A$2:$C$33,MATCH(«Austin»,$B$2:$B$33,0),3),»m/d/yy»)

3154

Atlanta

4/11/12

=»Dallas = «&INDEX($A$2:$C$33,MATCH(«Dallas»,$B$2:$B$33,0),1)& «, Invoice date: » & TEXT(INDEX($A$2:$C$33,MATCH(«Dallas»,$B$2:$B$33,0),3),»m/d/yy»)

3191

Atlanta

4/21/12

=»New Orleans = «&INDEX($A$2:$C$33,MATCH(«New Orleans»,$B$2:$B$33,0),1)& «, Invoice date: » & TEXT(INDEX($A$2:$C$33,MATCH(«New Orleans»,$B$2:$B$33,0),3),»m/d/yy»)

3293

Atlanta

4/25/12

=»Tampa = «&INDEX($A$2:$C$33,MATCH(«Tampa»,$B$2:$B$33,0),1)& «, Invoice date: » & TEXT(INDEX($A$2:$C$33,MATCH(«Tampa»,$B$2:$B$33,0),3),»m/d/yy»)

3331

Atlanta

4/27/12

3350

Atlanta

4/28/12

3390

Atlanta

5/1/12

3441

Atlanta

5/2/12

3517

Atlanta

5/8/12

3124

Austin

4/9/12

3155

Austin

4/11/12

3177

Austin

4/19/12

3357

Austin

4/28/12

3492

Austin

5/6/12

3316

Dallas

4/25/12

3346

Dallas

4/28/12

3372

Dallas

5/1/12

3414

Dallas

5/1/12

3451

Dallas

5/2/12

3467

Dallas

5/2/12

3474

Dallas

5/4/12

3490

Dallas

5/5/12

3503

Dallas

5/8/12

3151

New Orleans

4/9/12

3438

New Orleans

5/2/12

3471

New Orleans

5/4/12

3160

Tampa

4/18/12

3328

Tampa

4/26/12

3368

Tampa

4/29/12

3420

Tampa

5/1/12

3501

Tampa

5/6/12

The Combo of VLOOKUP and MATCH is like a superpower. Well, as we all know VLOOKUP is one of the most popular functions.

Right?

It can help you quickly lookup a value in a column. But when you use it more and more you will realize some problems with it. And, the biggest problem is it’s not dynamic.

In VLOOKUP, col_index_no is a static value which is the reason VLOOKUP doesn’t work as a dynamic function. And this is where you need to combine VLOOKUP with MATCH. 

If you are working on multiple-column data, it’s a pain to change its reference you have to do (change the column number) manually.

The best way to solve this problem is to use the MATCH function in VLOOKUP for col_index_number. Today in this post, I going to explain all the stuff you need to know to use this combo formula.

Problems With VLOOKUP

I have found the two biggest reasons to create a combination of these two functions.

1. Static Reference

Just look at the below data table where you have 12-month sales for four different employees.

Now, let’s say you want to look up the Feb month’s sale of “John”. The formula should be like this.

=VLOOKUP("May",A1:E13,2,0)

And in this formula, you have mentioned 2 as the col_index_num because John’s sale is in the second column. But what will you do if your boss tells you to get the sales value for “Peter”?

You need to change the value in col_index_num because it’s not dynamic.

2. Add or Delete Columns

Now think in a different way. You need to add a new column for a new employee just before John’s column.

And here, John’s column number is 3 and your formula result is incorrect.

Again here, because col_index_num is a static value you need to change it manually from 2 to 3 and again if you need something else.

At this point, you are clear about one thing you need to make col_index_num dynamic. And for this, the best way is to replace it with the MATCH function.

Why Match Function

Before you combine VLOOKUP and MATCH, you need to understand the match function and its work. The basic use of MATCH is to find the cell number of the lookup value from a range.

Syntax: MATCH(lookup_value,lookup_array,[match_type])

It has mainly three arguments, lookup value, a range to lookup for the value, and the match type to specify an exact match or an approximate match.

For example, in the below data, I am lookup for the name “John” with the match function from a heading row.

And, it has returned 2 in the result because the name is in the 2nd cell of the row.

VLOOKUP and MATCH Together

Now, it’s time to put VLOOKUP and MATCH together. So, let’s continue with our previous example.

First of all, let’s create a formula by using both of the functions, and then we’ll understand how these two work together.

Steps to create this combo formula:

  • First of all, in one cell enter the month’s name, and in another cell enter the employee’s name.
  • After that, enter the below formula in the third cell.
=VLOOKUP(C15,A1:E13,MATCH(C16,A1:E1,0),0)

In the above formula, you have used VLOOKUP to lookup for the MAY month, and for the col_index_num argument, you have used the match function instead of a static value.

And in the match function, you have used “John” (employee name) for the lookup value.

Here match function has returned the cell number for the “John” from the above row. After that, VLOOKUP used that cell number to return the value.

In simple words, the MATCH function tells VLOOKUP the column number to get the value from.

Problems Solved?

Above you have learned about two different problems which are because of static col_index_num.

And, for this, you have combined VLOOKUP and MATCH. Now, we need to check whether those problems are solved or not.

1. Static Reference

You have referred to the employee name in the match function to get the column number for VLOOKUP.

When you change the employee name in the cell, the match function will change the column number. And when you need to get the value for a different employee you have to change the employee name in the cell.

This way, you have a dynamic col_index_number.

Finally, you don’t have to edit the formula again and again.

2. Add or Delete Columns

Before adding a new column John’s data was in the 2nd column and the match function returned 2. And after you have inserted a new column john’s data is in the 3rd column and the match returned 3.

When you add a new column for a new employee the value in the formula is not changed because the match function updates its value.

In this way, you’ll always get the correct column number even when you insert/delete any column. The MATCH function will return the right column number.

  • Sample-File

VLOOKUP and INDEX-MATCH in Excel (Power Functions)

VLOOKUP and INDEX-MATCH formulas are among the most powerful functions in Excel. Lookup formulas come in handy whenever you want to have Excel automatically return the price, product ID, address, or some other associated value from a table based on some lookup value. The VLOOKUP function can be used when the lookup value is in the left column of your table or when you want to return the last value in a column. The INDEX and MATCH functions can be used in combination to do the same thing, but provide greater flexibility without some of the limitations of VLOOKUP. I’ll also mention LOOKUP and CHOOSE and EXACT and ISBLANK and ISNUMBER and ISTEXT and … 🙂, but this article is mainly about VLOOKUP and INDEX-MATCH.

To see these examples in action, download the Excel file below.

Download the Example File (LookupFormulas.xlsx)

Do you have a VLOOKUP or INDEX-MATCH challenge you need to solve? If you can’t figure it out after reading this article, go ahead and ask your question by commenting below.

This Article (bookmarks):

  • Simple VLOOKUP and INDEX-MATCH Examples
  • Wildcard Characters for Partial Match Lookups
  • Approximate Match Lookups (for Grades, Discounts, Taxes, etc.)
  • 2D Lookups Using VLOOKUP-MATCH and INDEX-MATCH-MATCH
  • 3D Lookups Using INDEX-MATCH and VLOOKUP
  • Case-Sensitive EXACT Lookup Using INDEX-MATCH
  • Multiple-Criteria Exact Lookups Using VLOOKUP and INDEX-MATCH
  • Lookups with Multiple Non-Exact Criteria Using INDEX-MATCH
  • Return the Last Numeric Value in a Column
  • Return the Last Text Value in a Column
  • Return the Last Non-BLANK Value in a Range
  • Return the Last Non-Empty Value in a Range
  • Lookup based on the Nth Match

1) Simple VLOOKUP and INDEX-MATCH Examples

VLOOKUP Example

First, here is an example of the VLOOKUP function using a simple Price List Table. We’re looking for the text «a_003» within the Item ID column and wanting to return the corresponding value from the Price column.

Excel VLOOKUP Function Example

=VLOOKUP(lookup_value,table_array,col_index_num,FALSE)

How it works: The table_array argument is a range that must have the lookup column on the left. The price column is the 3rd column in the highlighted range, so that is why the col_index_num argument is 3 in our example. We use FALSE for the final argument because we want the VLOOKUP function to do an exact match.

NOTES Actually, this lookup is not truly «exact» because both VLOOKUP and MATCH are not case-sensitive, but the syntax tooltip in Excel calls the option an «exact match» so we’ll just accept that and explain how to do a case-sensitive match later.

If you later insert a column in the middle of your table_array, the Price column might not be column 3 any more. To prevent your VLOOKUP formula from breaking, in place of the 3 in the example, you can use (COLUMN($E$30)-COLUMN($C$30)+1).

The default for VLOOKUP is not an exact match, so don’t forget to include FALSE as the 4th argument if you want an exact match.

INDEX-MATCH Example

Next, you’ll see that the INDEX-MATCH formula is just as simple:

Excel INDEX-MATCH Function Example

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

How it works: The MATCH function returns the position number 3 because «a_003» matches the 3rd row in the Item ID range. Next, INDEX(result_range,3) returns the 3rd value in the price list range.

The INDEX-MATCH formula is an example of a simple nested function where we use the result from the MATCH function as one of the arguments for the INDEX function. The example below shows this being done in two separate steps.

How the INDEX-MATCH Function Works

Syntax and Notes for MATCH and INDEX

MATCH returns the position number of a matched value within the lookup range.

=MATCH(lookup_value,lookup_range,match_type)

NOTES When using MATCH, the lookup_range can be a row or column, but if lookup_range is more than one row or column, MATCH will return an error.

MATCH returns the #N/A error when it does not find a match.

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

INDEX returns a value from an array based on a row and column number.

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

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

The optional area_number argument is only used for 3D arrays.

If your array is a row, don’t use the shortcut =INDEX(array,column_number) because that may not be compatible with other spreadsheet software. Use =INDEX(array,1,column_number) instead.

2) Use Wildcard Characters (?, *) for Partial Matches with VLOOKUP and INDEX-MATCH

Wildcard characters can be used within the lookup_value for both VLOOKUP and MATCH formulas when the lookup is text and you are doing an exact match.

Using Wildcard Characters in VLOOKUP and INDEX-MATCH

* (asterisk) matches any number of characters. For example, use «*200» to find the first value ending in 200.

? (question mark) matches any single character. For example, use «A?C*» to find the first value where «A» is the first character and «C» is the 3rd character. The second character can be anything, but only a single character.

~ (tilde) is used in front of a wildcard character to treat it as a literal character. In the 3rd example, we use «*~?*» to find the first occurrence of a product that contains an actual question mark.

3) Return Approximate Matches Using VLOOKUP and INDEX-MATCH

The following examples show how to use VLOOKUP and INDEX-MATCH to return approximate matches with numerical lookup data. Important: When using an «Approximate Match» with VLOOKUP (where the 4th argument = TRUE) and a «Less than» match with MATCH (where the 3rd argument = 1), the lookup range needs to be sorted in ascending order.

These formulas look for the largest value that is less than or equal to the lookup value.

=VLOOKUP(lookup_value,table_array,col_index_num,TRUE)
=INDEX(result_range,MATCH(lookup_value,lookup_range,1))

Example 1: Return a Grade based on Percent

Lookup Grades Using VLOOKUP

► See this in action: Download the Grade book Template

Example 2: Return a Discount Rate based on Quantity

Discount Rate Lookup Using INDEX-MATCH

Example 3: Return a Tax Rate based on Income

Tax Rate Lookup Using VLOOKUP

► See this in action: Download the Paycheck Calculator

CAUTION For an approximate match, these formulas use a very efficient search algorithm that assumes the lookup range is sorted in ascending order. If your data is not sorted, they don’t return an error value, but the result may be unpredictable.

If the lookup value is less than the first value in the lookup range, MATCH and VLOOKUP will return an error.

4) 2D Lookups Using VLOOKUP-MATCH and INDEX-MATCH-MATCH

In this example, we’ll do a mileage lookup between two cities. The formulas are basically the same as for a 1D lookup, except that we use a MATCH function to replace col_index_num in the VLOOKUP function and to replace column_number in the INDEX function.

2D Lookup Using VLOOKUP-MATCH

Using VLOOKUP

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

Using INDEX-MATCH-MATCH

=INDEX( result_array,
MATCH(row_lookup_value,row_label_range,0),
MATCH(column_lookup_value,column_label_range,0) )

Using HLOOKUP

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

5) 3D Lookups Using INDEX-MATCH and VLOOKUP

To demonstrate a 3D lookup, we’ll use mileage tables again, but this time we have a separate table for Road and Plane. The INDEX function allows you to return a value from a 3D array. You can replace the row_number, column_number, and area_number with 3 MATCH functions.

NOTE The reference argument for the INDEX function should be multiple same-size ranges surrounded by parentheses like this: (A1:D10,E1:H10), or you can use a named range.

=INDEX( (array_range1,array_range2) ,
MATCH(row_lookup_value,row_label_range,0),
MATCH(column_lookup_value,column_label_range,0),
MATCH(table_lookup_value,{"Road","Plane"},0) )

3D Lookup Using INDEX-MATCH

3D Lookup Using VLOOKUP

It is possible to do a 3D lookup using VLOOKUP. Starting with the 2D lookup formula, in place of array_table, you can use CHOOSE(table_number,table_array_1,table_array_2). You can use MATCH to find the value for table_number as in the INDEX-MATCH example above. The resulting formula would look like this:

=VLOOKUP(row_lookup_value, CHOOSE( MATCH(table_name,{"Road","Plane"},0), road_table_array, plane_table_array), MATCH(column_lookup_value,column_label_range,0), FALSE)

6) Case-Sensitive EXACT Lookup Using INDEX-MATCH

Most lookups and logical comparisons in Excel are NOT case-sensitive, meaning that both «A»=»a» and «A»=»A» would return TRUE.

The EXACT(value1,value2) function allows you to make a comparison between value1 and value2 that IS case sensitive, so EXACT(«A»,»a») returns FALSE and EXACT(«B»,»B») returns TRUE.

If you use EXACT to compare a value to a range like EXACT(«B»,A1:A20), the function returns an array of TRUE and FALSE values. You can then use a MATCH function to look for the value TRUE within the range returned by EXACT(lookup_value,lookup_range). The final lookup formula is an Excel Array Formula, so you need to press Ctrl+Shift+Enter after entering the formula.

{Ctrl+Shift+Enter} =INDEX(result_range, MATCH(TRUE,EXACT(lookup_value,lookup_range),0) )

Case-Sensitive EXACT Lookup Using INDEX-MATCH

See the references at the end of this article if you are curious about how a case-sensitive lookup can be done with VLOOKUP.

7) Multiple-Criteria Exact Lookups Using VLOOKUP and INDEX-MATCH

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

Multiple-criteria lookup using VLOOKUP and a helper column

VLOOKUP with Multiple Criteria

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

Multiple-criteria lookup using INDEX-MATCH as an array formula

INDEX-MATCH with Multiple Criteria

{Ctrl+Shift+Enter}  =INDEX(result_range,MATCH(value1 & value2, lookup_col1 & lookup_col2,0))

8) 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 method I like is to use INDEX-MATCH and convert the lookup_range to a TRUE or FALSE expression like lookup_range<lookup_value. Then search for the first occurrence of TRUE (using 1 as the first argument of the MATCH function). Using this method, you can have any number of conditions because multiplying true/false expressions together acts like the logical AND operator. The formula must be entered as an array formula (Ctrl+Shift+Enter), but that’s a small price to pay for relative simplicity.

INDEX-MATCH with Multiple Non-Exact Criteria

{Ctrl+Shift+Enter}  =INDEX(result_range,MATCH(1, (lookup_col1>lookup_value1) * (lookup_col2<lookup_value2) ,0) )

9) Return 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 column if you use an extremely large number as the lookup value (to make sure it will be larger than any number in the lookup range). A common example would be to return the last value in a Balance column for a checkbook register as shown in the example below.

Return the Last Numeric Value in a Column - VLOOKUP

=VLOOKUP( 9E+100, lookup_column, 1, TRUE)

Recall that the TRUE option (for an approximate match) is the default for VLOOKUP, so that is why the formula in the checkbook example image only shows 3 arguments.

This can of course be done with INDEX-MATCH, but I prefer the VLOOKUP formula in this case because it requires only one reference to the lookup column.

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

NOTES The lookup_column can contain text values and even errors (like #N/A or #DIV/0), and those values will be ignored. The formula returns only the last numeric value.

10) Return the Last Text Value in a Column

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

=VLOOKUP( "zzzzzzz", lookup_column, 1, TRUE)
=INDEX( lookup_column, MATCH( "🗿", lookup_column, 1) )

Rather than returning the last text value, I often use just the MATCH part of this formula to return the row number of the last value. This allows you to make a dynamic named range that can be used as the source range for a drop-down list via data validation.

11) Return the Last Non-BLANK Value in a Column

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

=INDEX( lookup_column, MAX( MATCH( "zzzzzz", lookup_column, 1), MATCH(9E+100, lookup_column,1) ) )

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

Return the Last Non-Blank Value Using LOOKUP

=LOOKUP(42, 1/NOT(ISBLANK(lookup_range)), lookup_range)

The trick here is that the expression 1/NOT(ISBLANK(lookup_range)) returns an array of 1s for TRUE and #DIV/0 errors for FALSE. LOOKUP ignores the error values so it will return the last value in lookup_range that is not blank. The number 42 is arbitrary — it just needs to be larger than 1 to return the last value.

Using very similar formulas, you can use LOOKUP to return just the last numeric value or text value like this:

=LOOKUP( 42, 1/ISNUMBER(lookup_range), result_range)
=LOOKUP( 42, 1/ISTEXT(lookup_range), result_range)

12) 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 the last value in the range, you can use the LOOKUP formula mentioned in the last example with the expression 1/(lookup_range<>»»).

Return the Last Non-Empty Value

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

If you want to return the relative row number instead of the actual value, you can use the following formula:

=LOOKUP(42, 1/(lookup_range<>""), ROW(lookup_range)-ROW(first_cell_in_lookup_range)+1 )

13) Lookup based on the Nth Match

You can use the SMALL function to return the Nth smallest value from an array, and we can use that along with an array formula and the INDEX function to do a lookup based on the Nth match. See my Array Formula Examples article to learn more about Array Formulas and specifically the SMALL-IF formula.

In this example, we want to return the 2nd Event that matches the date 3/7/2018. Note: The curly { } brackets in the formula below are a reminder to press Ctrl+Shift+Enter to enter the formula as an Array Formula. You don’t actually type the brackets into the formula.

Lookup Based on the Nth Match

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

How does this work? The SMALL-IF part of the formula is acting kind of like the MATCH function except that it is returning the index number for the 2nd occurrence of the match. We can use SMALL in this example because Excel stores dates as numbers.

This formula is used within the Daily Planner Template to list events and holidays occurring on a particular date.

14) VLOOKUP vs. INDEX-MATCH

Excel people like to debate about whether VLOOKUP is better than INDEX-MATCH for lookup formulas. The most common argument is that VLOOKUP is simpler and INDEX-MATCH is more powerful. Even though I usually prefer INDEX-MATCH, I think both formulas are pretty simple, and one isn’t necessarily always more powerful than the other.

If you want to do more advanced lookups with VLOOKUP, then you’ll probably need to learn how to use MATCH and CHOOSE. If you want to become a power Excel user, then you’ll also want to learn the INDEX function. So, my opinion on the VLOOKUP vs. INDEX-MATCH debate is to learn how to use them all.

In conclusion, here are some reminders applicable to both VLOOKUP and INDEX-MATCH:

  • Don’t forget the FALSE or 0 option if you are wanting an exact match, because the default parameter is to use an approximate match.
  • As a general rule, use absolute ($A$1) cell references to refer to the lookup ranges and table arrays because when you copy the lookup formula you will usually want those ranges to remain the same.
  • Check for extra blank spaces if you think a lookup formula should be finding a match, but it is not.
  • Use IFERROR to handle the error returned when an exact match is not found.

References

  • Spreadsheet Tips Workbook — vertex42.com — by Jon Wittwer and Brent Weight
  • VLOOKUP Function — support.office.com — The official documentation of the VLOOKUP function.
  • MATCH Function — support.office.com — The official documentation of the MATCH function.
  • INDEX Function — support.office.com — The official documentation of the INDEX function.
  • Case-Sensitive Match Using VLOOKUP — at ablebits.com — This shows that it IS possible, but the solution is quite complex.
  • Get Value of Last Non-Empty Cell — at exceljet.net — I think this article explains the LOOKUP function better than I did.

VLOOKUP formula works only when the table array in the formula does not change. Still, if a new column is inserted into the table or a column is deleted, the formula gives an incorrect result or reflects an error. To make the formula error-free in such dynamic situations, we use the MATCH function to match the data’s index and return the actual result.

Table of contents
  • Combine VLOOKUP with Match
    • VLookup and Match Formula
      • #1 – VLOOKUP Formula
      • #2 – Match Formula
      • #3 –  VLOOKUP with  MATCH Formula
    • How to Use VLOOKUP with Match Formula in Excel?
    • Things to Remember
    • Recommended Articles

Combine VLOOKUP with Match

The VLOOKUP formula is the most commonly used function to search and return either the same value in the specified column index or the value from a different column index concerning the matched value from the first column. The major challenge faced while using VLOOKUP is that the column index to be specified is static and does not have dynamic functionality. Especially when you are working on multiple criteria that require you to change the reference column index manually, this need is fulfilled by using the “MATCH” formula to have a better grip or control of the frequently changing column index in the VLOOKUP formula.

VLOOKUP with Match

You are free to use this image on your website, templates, etc, Please provide us with an attribution linkArticle Link to be Hyperlinked
For eg:
Source: VLOOKUP with Match (wallstreetmojo.com)

VLookup and Match Formula

#1 – VLOOKUP Formula

The formula of the VLOOKUP function in Excel:

Vlookup & Match Formula

Here, all the arguments to be entered are mandatory.

  • lookup_value Here, a reference cell or text with double quotes should be entered to be identified in the column range.
  • table_array This argument requires the table range to be entered where the lookup_value should be searched and the data to be retrieved resides in the particular column range.
  • col_index_num In this argument, the column index number or the count of the column from the reference first column needs to be entered from which the corresponding value needs to be pulled from the same position as the value searched in the first column.
  • [Range_lookup] – This argument will give two options.
  • TRUE – Approximate match:- The argument can either be entered as “TRUE” or numeric “1”, which returns the approximate match corresponding to the reference column or first column. Moreover, we must sort values in the first column of the table array in ascending order.
  • FALSE – Exact match:- Here, the argument to be entered can either be “FALSE” or numeric “0”. This option will only return the exact match of the value corresponding to be identified from the position in the first column range. Failure to search the value from the first column would return a #N/A error message.

#2 – Match Formula

Vlookup & Match Formula 1

The MATCH function returns the cell position of the value entered for the table array.

All the arguments within the syntax are mandatory.

  • lookup_value – The argument entered can be either the cell reference of the value or a text string with double quotes whose cell position is required to be pulled.
  • lookup_array – The table array range must be entered whose value or cell content is desired to be identified.
  • [match type] – This argument provides three options, as explained below.
  • “1-Less than” The argument to be entered is numeric “1,” which will return the value that is less than or equal to the lookup value. And also, we must sort the lookup array in ascending order.
  • “0-Exact match” – The argument to be entered should be numeric “0”. This option will return the exact position of the matched lookup value. However, the lookup array can be in any order.
  • “-1-Greater than” – The argument to be entered should be numeric “-1”. The third option finds the smallest value greater than or equalThe “greater than or equal to” is a comparison or logical operator that helps compare two data cells of the same data type.read more to the lookup_value. Here, we must place the order for the lookup array in descending order.

#3 –  VLOOKUP with  MATCH Formula

=VLOOKUP(lookup_value, table_array, MATCH(lookup_value, lookup_array, [match_type]),[range lookup])

How to Use VLOOKUP with Match Formula in Excel?

The example below will help understand the functioning of the VLOOKUP and MATCH formula when put together.

You can download this VLookup with Match Excel Template here – VLookup with Match Excel Template

Consider the below data tableA data table in excel is a type of what-if analysis tool that allows you to compare variables and see how they impact the result and overall data. It can be found under the data tab in the what-if analysis section.read more, which describes the specifications of the given vehicle to be purchased.

Vlookup & Match Formula examples 1

To clarify the combined function for the VLOOKUP and MATCH function, let us understand how the individual formula operates and then arrive at the VLOOKUP MATCH results when put together.

Step #1 – Let us apply the VLOOKUP formula at an individual level to arrive at the result.

Vlookup & Match Formula examples 1-2

The output is shown below:

Vlookup & Match Formula examples 1-3

Here, the lookup_value is referred to as $B9, is model “E,” and the lookup_array is given as the range of the data table with absolute value “$” the column_index is referred to as column “4,” which is the count for column “Type,” and the range lookup is given an exact match.

Thus, the following formula is applied for returning the value for column “Fuel.”

Vlookup & Match Formula examples 1-4

The output is shown below:

Vlookup & Match Formula examples 1-5

Here, the lookup_value with absolute string “$” applied for lookup value and lookup_array helps fix the reference cell even if the formula is copied to a different cell. For example, in the “Fuel” column, we need to change the column index to “5” as the value from which the data required to be retrieved changes.

Step #2 – Now, let us apply the MATCH formula to retrieve the position for the given lookup_value.

Vlookup & Match Formula examples 1-6

The output is shown below:

Vlookup & Match Formula examples 1-7

As the above screenshot shows, we are trying to retrieve the column position from the table array. In this case, the column number to be pulled is called cell C8, column “Type,” and the lookup_range to be searched is given as the range of column headers, and the match type is given an exact match to be as “0”.

Thus, the below table will give the desired result for the positions of column “Fuel.”

Vlookup & Match Formula examples 1-8

Here, the column searched is given to be cell D8, and the desired column_index is returned to be “5”.

Vlookup & Match Formula examples 1-9

Step #3 – We will use the MATCH formula within the VLOOKUP function to get the value from the identified column position.

examples 1-10

The output is shown below:

examples 1-11

In the above formula, the MATCH function is put in place of the column_index parameter of the VLOOKUP function. Here, the MATCH function will identify the lookup_value reference cell “C8” and return the column number through the table array. This column position will serve as an input to the column index argument in the VLOOKUP function. Which, in turn, will help VLOOKUP identify the value returned from the resultant column index number?

Similarly, we have also applied VLOOKUP with a MATCH formula for the “Fuel” column.

examples 1-12

The output is shown below:

examples 1-13

We can thereby apply this combination function for other columns “Type” and “Fuel” as well.

examples 1-14

Things to Remember

  • We can apply VLOOKUP to lookup values only on its foremost left-hand side. Any values present to be searched on the right side of the data table will return the #N/A error value.
  • The range of table_array entered in the second argument should be absolute cell referenceAbsolute reference in excel is a type of cell reference in which the cells being referred to do not change, as they did in relative reference. By pressing f4, we can create a formula for absolute referencing.read more “$” because it will maintain the fixed table array range when applying the lookup formula to other cells. Otherwise, the table_array, range reference cells will shift to the next cell reference.
  • The value entered in the lookup_value should not be smaller than the smallest value in the first column of the table array. Else, the function will return the #N/A error value.
  • Before applying an approximate match “TRUE” or “1” in the last argument, we must always remember to sort the table array in ascending order.
  • The MATCH function only returns the position of the value in the vlookup table arrayWhen we use a reference cell or value to search in a group of columns containing data to be matched and retrieve the output in the VLOOKUP table array or vertical lookup, the range we use is called VLOOKUP table array.read more and does not return the value.
  • If the MATCH function cannot identify the position of the lookup_value in the table array, then the formula returns #N/A in the error value.
  • VLOOKUP and MATCH functions are case insensitive when matching the lookup_value with the matching text value in the table_array.

Recommended Articles

This article is a guide to VLOOKUP with MATCH Function. Here, we learn how to create a flexible formula using VLOOKUP MATCH in Excel and a practical example and downloadable Excel sheet. You may learn more about Excel from the following articles: –

  • Excel VLOOKUP FormulaThe VLOOKUP excel function searches for a particular value and returns a corresponding match based on a unique identifier. A unique identifier is uniquely associated with all the records of the database. For instance, employee ID, student roll number, customer contact number, seller email address, etc., are unique identifiers.
    read more
  • VLOOKUP Errors
  • Vlookup to the LeftVlookup to the left finds the respective values which are in the left column of the reference cell. Index, and match are such formulas which are combined together or we can use conditional formulas in the lookup function to find values to the left.read more
  • VLookup Function with IFIn Excel, vlookup is a reference function, and IF is a conditional statement. Based on the results of the Vlookup function, they locate a value that meets the criteria and also matches the reference value.read more

VLOOKUP MATCH is one of several possible lookup formulas within Microsoft Excel.  This tutorial assumes you already have a decent understanding of how to use VLOOKUP.  If you do not, please click here for a beginner’s tutorial on VLOOKUP.

VlookMatch8

Objective

VLOOKUP MATCH is an improved variation of your basic VLOOKUP or INDEX MATCH formula.  Using VLOOKUP MATCH allows you to perform a matrix lookup – instead of just looking up a vertical value, the MATCH portion of the formula turns your column reference into a dynamic horizontal lookup as well.  VLOOKUP MATCH is mainly useful for situations where you intended to perform heavy editing on your data set after you’ve finished writing your formula.  This is because VLOOKUP MATCH gives your lookup formula insertion immunity; whenever you insert or delete a column within your lookup array, your formula will still pull the correct number.  VLOOKUP MATCH is actually very similar to VLOOKUP HLOOKUP, but is slightly better because it does not require the creation of an additional row to label your column numbers.

The key difference between using VLOOKUP MATCH versus the basic VLOOKUP formula is that, in addition to your vertical lookup value (what you’ll be looking up down the left side of your table) you’ll also have a column lookup value (what you’ll be looking up across the top of your column headings).

Excel Bestsellers

The Syntax

VLOOKUP and MATCH are the two formulas that are combined to perform this lookup.  We’ll look at each of the formulas separately before putting them together.  The primary formula we’ll be using is VLOOKUP:

=VLOOKUP ( lookup value table_array , col_index_num [range_lookup] )

To use this formula, you’ll need a lookup value and a table array.  (We’ll address the column index number later and since we are not performing a range lookup, we can leave that part of the syntax blank)  In the example below, the lookup value is ID number “5” and the table array is the green box surrounding cells B6:F14.

VlookMatch1

Next we have the MATCH formula:

=MATCH ( lookup value lookup_array , [match _type] )

The match formula returns a position number based on your lookup value’s location within the array you’ve selected.  To use this formula you’ll need both a lookup value and a lookup array.  (The match type parameter should be left blank – doing so tells Excel that we want an exact match).  In the example below, the lookup value we’ll be using is the State of “WA” and the lookup array is the orange box surrounding cells B6:F6.

VlookMatch2

Putting it Together

The key to VLOOKUP MATCH is that we are replacing the “column index number” syntax of VLOOKUP with the MATCH formula.  Perform this combination using the following steps:

Step 1: Start by typing your VLOOKUP formula as you normally would, inputting the proper lookup value and table array for your lookup; in this example the lookup value is ID number “5” and the table array is the green box surrounding cells B6:F14.

VlookMatch3

Step 2: When you get to the column index number input, instead of typing in a hard coded number, start typing in the MATCH formula

VlookMatch4

Step 3: For the MATCH formula’s lookup value, select the cell containing name of the column you want to return from; in this example we want to return a State, so we click on it

VlookMatch5

Step 4: For the MATCH formula’s lookup array, select the row headings of your table array; in this example it is the orange box surrounding cells B6:F6.

VlookMatch6

Step 5: Close off both your MATCH formula and your VLOOKUP formula with two parentheses (doing this simply confirms for Excel that we want an exact match for the MATCH formula and that we don’t want to use a range lookup for the VLOOKUP)

VlookMatch7

How it Works

The MATCH formula we created returns the value 4.  Therefore, based on how we arranged the syntax, the VLOOKUP MATCH in this state is basically performing the same function as a VLOOKUP with a column index number of 4.

VlookMatch8

However, the key difference is that this column reference is now dynamic.  If I insert or delete a column from my lookup table, my return value will stay the same.  See below for an example of the difference in return values between VLOOKUP and VLOOKUP MATCH after inserting a column.

VlookMatch9

After the insertion occurs, the VLOOKUP formula’s column reference remains 4 and is now pulling from the City field.  Your return value has changed from “WA” to “Seattle.”  However, with VLOOKUP MATCH, since you’ve indicated by name which column you want to pull from, the column reference automatically updates and therefore you maintain the “WA” return value.

Disadvantages

While VLOOKUP MATCH is clearly an improvement over the basic VLOOKUP, there are still drawbacks to using this formula.  With VLOOKUP MATCH, every lookup must still start from left to right.  This can become problematic if you want to append lookup keys to the right of your dataset.  Additionally, your return values are limited to the originally table array you’ve selected.  For example, if you were to append one or two columns to the right of your data set, you wouldn’t be able to lookup and return values from those columns without adjusting your table array.

If you want to use a matrix lookup formula combination without these specific limitations, consider using INDEX MATCH MATCH.

Return to Excel Formulas List

Download Example Workbook

Download the example workbook

This tutorial will demonstrate how to retrieve data from multiple columns using the MATCH and VLOOKUP Functions in Excel and Google Sheets.

vlookup match combined

Why Should you Combine VLOOKUP and MATCH?

Traditionally, when using the VLOOKUP Function, you enter a column index number to determine which column to retrieve data from.

This presents two problems:

  • If you want to pull values from multiple columns, you must manually enter the column index number for each column
  • If you insert or remove columns, your column index number will no longer be valid.

To make your VLOOKUP Function dynamic, you can find the column index number with the MATCH Function.

=VLOOKUP(G3,B3:E5,MATCH(H2,B2:E2,0),FALSE)

vlookup match combined 01

Let’s see how this formula works.

MATCH Function

The MATCH Function will return the column index number of your desired column header.

In the example below, the column index number for “Age” is calculated by the MATCH Function:

=MATCH("Age",B2:E2,0)

vlookup match combined 02

“Age” is the 2nd column header, so 2 is returned.

Note: The last argument of the MATCH Function must be set to 0 to perform an exact match.

VLOOKUP Function

Now, you can simply plug in the result of the MATCH Function into your VLOOKUP Function:

=VLOOKUP(G3,B3:E5,H3,FALSE)

vlookup match combined 03

Replacing the column index argument with the MATCH Function gives us our original formula:

=VLOOKUP(G3,B3:E5,MATCH(H2,B2:E2,0),FALSE)

vlookup match combined 04

Inserting and Deleting Columns

Now, when you insert or delete columns in the data range, the result of your formula will not change.

vlookup match combined 05

In the example above, we added the Teacher column to the range but still want the student’s Age. The output from the MATCH Function identifies that “Age” is now the 3rd item in the header range, and the VLOOKUP Function uses 3 as the column index.

Locking Cell References

To make our formulas easier to read, we’ve shown the formulas without locked cell references:

=VLOOKUP(G3,B3:E5,MATCH(H2,B2:E2,0),FALSE)

But these formulas will not work properly when copy and pasted elsewhere in your file. Instead, you should use locked cell references like this:

=VLOOKUP($G3,$B$3:$E$5,MATCH(H$2,$B$2:$E$2,0),FALSE)

Read our article on Locking Cell References to learn more.

VLOOKUP & MATCH Combined in Google Sheets

These formulas work exactly the same in Google Sheets as in Excel.

vlookup match combined Google

This post provides an explanation of how to use the VLOOKUP and MATCH functions to give you better control over how the column index number changes.  This is often referred to as a dynamic formula.  You will learn how this dynamic duo can help prevent errors and improve your VLOOKUP formulas.

Dynamic Duo VLOOKUP MATCH Excel

We are going to learn how the MATCH function can be used inside the VLOOKUP function.  This helps protect the VLOOKUP from returning errors when changes are made to the workbook.

Problems with VLOOKUPs

The VLOOKUP is a very useful function, but it doesn’t respond to change very well.  Have you ever noticed that if you add or delete columns in an area that the VLOOKUP refers to, the result can return an error or incorrect result?

VLOOKUP ERROR

This is usually due to the fact that we have specified the column number as a static number in the 3rd argument of the VLOOKUP argument.

VLOOKUP Static Column Number

The Starbucks Menu Example

We can use the Starbucks menu VLOOKUP example to help explain this issue.

Excel Vlookup Explained Column Index Number

In that example we wanted to return the price for the size Grande, which was in column 3 of the menu.  We put a “3” in the column index argument in the VLOOKUP formula to reference the Grande column (col C).

But what if Starbucks decided to add a new size to the menu?

Let’s say they decide to add a size “Short” to the menu, and put it to the left of the size Tall.

In our spreadsheet example, we would need to insert a column after column A for the new size.  This change means that the size Grande is now in column 4 (col D).

VLOOKUP Starbucks Menu Wrong Column Reference Add Col

However, our VLOOKUP still references column 3.  Excel does NOT update the formula when a column is inserted or deleted.

Therefore, the formula is now returning the wrong result.

This is a problem!  But fortunately for us, VLOOKUP has a side-kick named MATCH that will save the day.

MATCH to the Rescue

We first need to learn how the MATCH function works.

The MATCH function is very similar to the VLOOKUP.  It’s job is to look through a range of cells and find a match.

The difference is that it returns a row or column number.

Difference Between VLOOKUP and MATCH

So why the Batman and Robin reference?

I like to think of MATCH as VLOOKUP’s little brother, or side-kick.  They do very similar jobs, but MATCH packs a smaller punch.

Batman is the VLOOKUP and returns a big value in the form of a cell’s value.  This can be text or a number.

Robin is the MATCH and returns a smaller value in the form of a number.

Dynamic Duo Vlookup Value Match Number

Hopefully this will help you remember and distinguish the difference between the two.

The Match Function Components

The MATCH function’s arguments are similar to the VLOOKUP’s.  The following image shows the Excel definition of the VLOOKUP function, and then my simple definition.  This simple definition just makes it easier for me to remember the three arguments.

Match Simple Definition

I explain this simple definition below as we walk through an example of creating a VLOOKUP formula.

The MATCH Example

Let’s look at the Starbucks menu example again to learn MATCH.  In this example we want to use the MATCH function to return the column number for the size Grande.

I’ll explain why later, but for now we just want to answer the question:

“What is the column number for the size Grande?”

We will answer this question using the MATCH function.  You can download the file to follow along.

1. lookup_value – This is the what argument.

Match Explained Step 1 - What

In the first argument we tell the VLOOKUP what we are looking for.  In this example we are looking for “Grande” in row 1.  I have entered the text “Grande” in cell A14, so we can make a reference to cell A14 in the formula.

2. lookup_array – This is the where argument.

Match Explained Step 2 - Where

Here we need to tell MATCH where to look for the word “Grande”.  I selected the range $A$1:$D$1, which contains the column header names.  MATCH will look through row 1 from left-to-right until it finds a match.

You can also specify a column for this argument.  In that case MATCH would look down the column from top-to-bottom to find a match.

3. [match_type] – The match type tells MATCH how precise to be with the lookup.

Match Explained Step 3 - Match Type

Here we specify if the function should look for an exact MATCH, or a value that is less than or greater than the lookup_value.

In this example we will use “Exact match”, which is represented by putting a 0 (zero) in the third argument.  When your MATCH is looking up text you will generally want to look for an exact match.

If you are looking up numbers with the MATCH function then the “Less than” or “Greater than” match types can be very useful.

The Result – Grande is in column 3.

Match Explained Step 4 - Result

The MATCH function was able to lookup the word “Grande” in row 1 and return the value of 3 in cell B14.

Now let’s see how the MATCH function can be a little more dynamic.  In the following screenshot I inserted a column to the left of column B with a new size, “Short”.

Match Explained Add New Column

You will notice that the result of the MATCH formula changed to “4”.  This is because the word “Grande” is now in the 4th column of the lookup_array (A1:E1).

You are probably starting to see how this could help our original problem of the VLOOKUP returning the wrong result.

VLOOKUP & MATCH – The Dynamic Duo

Now let’s see how we can combine these two to create a dynamic formula.

We can use the MATCH function inside the VLOOKUP function.  Instead of specifying the column number with a static number “3”, we will use the MATCH function in its place.

Since the MATCH returns a number, it is a perfect fit for the VLOOKUP’s col_index_num argument.

The following example illustrates this.  You can follow along in the ‘VLOOKUP & MATCH Example’ sheet in the example file.

Vlookup Match Dynamic Formula Example Starbucks Menu

The original formula looked like the following:

=VLOOKUP(A14,$A$2:$E$10,4,FALSE)

In the new formula I replace the “4” with the MATCH formula:

=VLOOKUP(A14,$A$2:$E$10,MATCH(B14,$A$1:$E$1,0),FALSE)

The MATCH formula references cell B14, which contains the word “Grande”.  The formula looks up the word Grande in row 1 and returns a 4 as the result because Grande is in the fourth column of the range A1:E1.

The VLOOKUP formula is now much more dynamic with MATCH included.  We can add or delete columns to the menu (table), and the VLOOKUP will still return the price for the size that is specified in cell B14.

You could also change either the item in cell A14 or the size in cell B14 to return different prices in cell C14.

This makes the formula very flexible, and easier to reuse in other places in the workbook.

Conclusion

I hope this post has helped you understand how the VLOOKUP and MATCH functions can work together to be a dynamic duo.  This team of functions will help prevent errors in your formulas.  It will also help you create financial models that are more flexible for data retrieval and scenario analysis.

Series: The Lookup Functions Explained

This is the 2nd post in a series about the most commonly used lookup functions in Excel.

  1. In the first post I explained the VLOOKUP function at Starbucks.
  2. In this second post I explained how to make lookup formulas more dynamic with the VLOOKUP & MATCH functions.
  3. In the third post I explain the INDEX function.

Please leave a comment below with any questions or comments.

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 for new Excel users.

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:

VLOOKUP is for vertical data

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:

VLOOKUP is based on column numbers

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:

VLOOKUP can only look to the right

To look up 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 mode is the default, 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 an 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:

VLOOKUP exact match with movies

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

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

Approximate match example

In some cases, you will need an approximate match lookup instead of an exact match lookup. For example, below we want to find the correct commission percentage in the range G5:H10 based on the sales amount in 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 approximate match commission rate

=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.

Note: The table_array must be sorted in ascending order by lookup value to use an approximate match. If table_array is not sorted by the first column in ascending order, VLOOKUP may return incorrect or unexpected results.

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

VLOOKUP returns first match

Tip: To retrieve multiple matches with 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)

VLOOKUP wildcard match

Read a more detailed explanation here.

Two-way lookup

Inside the VLOOKUP function, column_index_num is normally hard-coded as a static number. However, you can 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 like this:

=VLOOKUP(H4,B5:E13,MATCH(H5,B4:E4,0),0)

VLOOKUP two-way lookup

For more details, see this example.

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)

VLOOKUP with multiple criteria

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:

VLOOKUP #N/A error example

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:

VLOOKUP #N/A error example - fixed

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 

More about VLOOKUP

  • VLOOKUP with multiple criteria (basic)
  • VLOOKUP with multiple criteria (advanced)
  • How to use VLOOKUP to merge tables
  • 23 tips for using VLOOKUP
  • More VLOOKUP examples and videos
  • XLOOKUP vs 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 with index in excel
  • Vlookup with and function in excel
  • Vlookup vba excel описание
  • Vlookup not found excel
  • Vlookup function for excel