*This tutorial explains how to use MATCH function in Excel with formula examples. It also shows how to improve your lookup formulas by a making dynamic formula with VLOOKUP and MATCH.*

In Microsoft Excel, there are many different lookup/reference functions that can help you find a certain value in a range of cells, and MATCH is one of them. Basically, it identifies a relative position of an item in a range of cells. However, the Excel MATCH function can do much more than its pure essence.

The MATCH function in Excel searches for a specified value in a range of cells, and returns the relative position of that value.

The syntax for the Excel MATCH function is as follows:

MATCH(lookup_value, lookup_array, [match_type])

**Lookup_value** (required) - the value you want to find. It can be a numeric, text or logical value as well as a cell reference.

**Lookup_array** (required) - the range of cells to search in.

**Match_type **(optional) - defines the match type. It can be one of these values: 1, 0, -1. The match_type argument set to 0 returns only the exact match, while the other two types allow for approximate match.

- 1 or omitted (default) - find the
**largest value**in the lookup array that is less than or equal to the lookup value. Requires sorting the lookup array in ascending order, from smallest to largest or from A to Z. - 0 - find the first value in the array that is
**exactly equal**to the lookup value. No sorting is required. - -1 - find the
**smallest value**in the array that is greater than or equal to the lookup value. The lookup array should be sorted in descending order, from largest to smallest or from Z to A.

To better understand the Excel MATCH function, let's make a simple formula based on this data: students names in column A and their exam scores in column B, sorted from largest to smallest. To find out where a specific student (say, *Laura*) stands among others, use this simple formula:

`=MATCH("Laura", A2:A8, 0)`

Optionally, you can put the lookup value in some cell (E1 in this example) and reference that cell in your Excel Match formula:

`=MATCH(E1, A2:A8, 0)`

As you see in the screenshot above, the student names are entered in an arbitrary order, and therefore we set the *match_type* argument to 0 (exact match), because only this match type does not require sorting values in the lookup array. Technically, the Match formula returns the relative position of Laura in the range being searched. But because the scores are sorted from largest to smallest, it also tells us that Laura has the 5^{th} best score among all students.

As you have just seen, using MATCH in Excel is easy. However, as is the case with nearly any Excel function, there are a few specificities that you should be aware of:

- The MATCH function returns the
**relative position**of the lookup value in the array, not the value itself. - MATCH is
**case-insensitive**, meaning it does not distinguish between lowercase and uppercase characters when dealing with text values. - If the lookup array contains several occurrences of the lookup value, the position of the first value is returned.
- If the lookup value is not found in the lookup array, the #N/A error is returned.

Now that you know the basic uses of the Excel MATCH function, let's discuss a few more formula examples that go beyond the basics.

Like many other Excel functions, MATCH understands the following wildcard characters:

- Question mark (?) - replaces any single character
- Asterisk (*) - replaces any sequence of characters

A Match formula with wildcards comes useful in situations when you want to match not the entire text string, but only some characters or some part of the string. To illustrate the point, consider the following example.

Supposing you have a list of regional resellers and their sales figures for the past month. You want to find a relative position of a certain reseller in the list (sorted by the Sales amounts in descending order) but you cannot remember his name exactly, though you do remember a few first characters.

Assuming the reseller names are in the range A2:A11, and you are searching for the name that begins with "car", the formula goes as follows:

`=MATCH("car*", A2:A11,0)`

To make our Match formula more versatile, you can type the lookup value in some cell (E1 in this example), and concatenate that cell with the wildcard character, like this:

`=MATCH(E1&"*", A2:A11,0)`

As shown in the screenshot below, the formula returns 2, which is the position of "Carter":

To replace just one character in the lookup value, use the "?" wildcard operator, like this:

`=MATCH("ba?er", A2:A11,0)`

The above formula will match the name "*Baker*" and rerun its relative position, which is 5.

As mentioned in the beginning of this tutorial, the Excel MATCH function doesn't distinguish uppercase and lowercase characters. To make a case-sensitive Match formula, use MATCH in combination with the EXACT function that compares cells exactly, including the character case.

The generic case-sensitive formula to match data in Excel is this:

MATCH(TRUE, EXACT(*lookup array*, *lookup value*), 0)

The formula works with the following logic:

- The EXACT function compares the lookup value with each element of the lookup array. If the compared cells are exactly equal, the function returns TRUE, FALSE otherwise.
- And then, the MATCH function compares TRUE (which is its
*lookup_value*) with each value in the array returned by EXACT, and returns the position of the first match.

Please bear in mind that it's an array formula that requires pressing Ctrl + Shift + Enter to be completed correctly.

Assuming your lookup value is in cell E1 and the lookup array is A2:A9, the formula is as follows:

`=MATCH(TRUE, EXACT(A2:A9,E1),0)`

The following screenshot shows the case-sensitive Match formula in Excel:

Checking two lists for matches and differences is one of the most common tasks in Excel, and it can be done in a variety of ways. An ISNA/MATCH formula is one of them:

`=IF(ISNA(MATCH(`

*1st value in List1*, *List2*, 0)), "Not in List 1", "")

For any value of List 2 that is not present in List 1, the formula returns "*Not in List 1*". And here's how:

- The MATCH function searches for a value from List 1 within List 2. If a value is found, it returns its relative position, #N/A error otherwise.
- The ISNA function in Excel does only one thing - checks for #N/A errors (meaning "not available"). If a given value is an #N/A error, the function returns TRUE, FALSE otherwise. In our case, TRUE means that a value from List 1 is not found within List 2 (i#N/A error is returned by MATCH).
- Because it may be very confusing for your users to see TRUE for values that do not appear in List 1, you utilize the IF function to display "
*Not in List 1*" instead, or whatever text you want.

Supposing you are comparing values in column B with values in column A, the formula takes the following shape (where B2 is the topmost cell):

`=IF(ISNA(MATCH(B2,A:A,0)), "Not in List 1", "")`

As you remember, the MATCH function in Excel is case-insensitive by itself. To get it to distinguish the character case, embed the EXACT function in the *lookup_array* argument, and remember to press Ctrl + Shift + Enter to complete this **array formula**:

`=IF(ISNA(MATCH(TRUE, EXACT(A:A, B2),0)), "Not in List 1", "")`

The following screenshot shows both formulas in action:

To learn other ways to compare two lists in Excel, please see the following tutorial: How to compare 2 columns in Excel.

This example assumes you already have some basic knowledge of Excel VLOOKUP function. And if you do, chances are that you've run into its numerous limitations (the detailed overview of which can be found in Why Excel VLOOKUP is not working) and are looking for a more robust alternative.

One of the most annoying drawbacks of Excel VLOOKUP is that it stops working after inserting or deleting a column within a lookup table. This happens because VLOOKUP pulls a matching value based on the number of the return column that you specify (index number). Because the **index number** is "hard-coded" in the formula, Excel is unable to adjust it when a new column(s) is added to or deleted from the table.

The Excel MATCH function deals with a **relative position** of a lookup value, which makes it a perfect fit for the *col_index_num* argument of VLOOKUP. In other words, instead of specifying the return column as a static number, you use MATCH to get the current position of that column.

To make things easier to understand, let's use the table with students' exam scores again (similar to the one we used at the beginning of this tutorial), but this time we will be retrieving the real score and not its relative position.

Assuming the lookup value is in cell F1, the table array is $A$1:$C$2 (it's a good practice to lock it using absolute cell references if you plan to copy the formula to other cells), the formula goes as follows:

`=VLOOKUP(F1, $A$1:$C$8, 3, FALSE)`

The 3^{rd} argument (*col_index_num*) is set to 3 because the *Math Score* that we want to pull is the 3^{rd} column in the table. As you can see in the screenshot below, this regular Vlookup formula works well:

But only until you insert or delete a column(s):

So, why the #REF! error? Because *col_index_num* set to 3 tells Excel to get a value from the third column, whereas now there are only 2 columns in the table array.

To prevent such things from happening, you can make your Vlookup formula more dynamic by including the following Match function:

`MATCH(E2,A1:C1,0)`

Where:

- E2 is the lookup value, which is
**exactly equal**to the name of the return column, i.e. the column from which you want to pull a value (*Math Score*in this example). - A1:C1 is the lookup array containing the table headers.

And now, include this Match function in the *col_index_num* argument of your Vlookup formula, like this:

`=VLOOKUP(F1,$A$1:$C$8, MATCH(E2,$A$1:$C$1, 0), FALSE)`

And make sure it works impeccably no matter how many columns you add or delete:

In the screenshot above, I locked all cell references for the formula to work correctly even if my users move it to another place in the worksheet. A you can see in the screenshot below, the formula works just fine after deleting a column; furthermore Excel is smart enough to properly adjust absolute references in this case:

In a similar manner, you can use the Excel Match function to improve your HLOOKUP formulas. The general principle is essentially the same as in case of Vlookup: you use the Match function to get the relative position of the return column, and supply that number to the *row_index_num* argument of your Hlookup formula.

Supposing the lookup value is in cell B5, table array is B1:H3, the name of the return row (lookup value for MATCH) is in cell A6 and row headers are A1:A3, the complete formula is as follows:

`=HLOOKUP(B5, B1:H3, MATCH(A6, A1:A3, 0), FALSE)`

As you have just seen, the combination of Hlookup/Vlookup & Match is certainly an improvement over regular Hlookup and Vlookup formulas. However, the MATCH function doesn't eliminate all their limitations. In particular, a Vlookup Match formula still cannot look at its left, and Hlookup Match fails to search in any row other than the topmost one.

To overcome the above (and a few other) limitations, consider using a combination of INDEX MATCH, which provides a really powerful and versatile way to do lookup in Excel, superior to Vlookup and Hlookup in many respects. The detailed guidance and formula examples can be found in INDEX & MATCH in Excel - a better alternative to VLOOKUP.

This is how you use Match formulas in Excel. Hopefully, the examples discussed in this tutorial will prove helpful in your work. If someone wants to have a closer look at the formulas, you are welcome to download the Sample Excel MATCH workbook. I thank you for reading and hope to see you on our blog next week.

Excel formulas
Excel functions
Vlookup in Excel
Merge data in Excel
SumIf
Excel CountIf
Excel Compare
Excel If statement
Excel Charts
Pivot Table
Excel conditional formatting
Excel formatting
Excel time
Excel duplicates
Excel date
Excel tips
Excel macro
Outlook
Google Sheets
Outlook duplicates
Outlook templates

## 23 Responses to "How to use MATCH function in Excel - formula examples"

i have table with daily entry

c column to add 1 when A1 is 14 or less, in same time if A1 more than 14

d column give 1

the problem is A1 is increasing every day and i don't want column C to give me zero when A1 more than 14

thank you for help.

Your are good. Your presentation is so awesome. Thanks a lot.

Brilliant work- Am sharing this link to everyone.

Really impressive; I'm really curious about the huge world of excel formulas. I hope I'll learn some of them. You are doing a great job with writing blogs like this.. everyone who wants to learn excel (especially excel formulas) will be thankful for this.

Useful, very detailed explanation, thanks a lot!

Thankful! to you.

Very useful and perfect.

Hello,

I understand all of this very well, when lookup_array is a 1-dimensional array.

But, what if lookup_array is a 2-dimensional array?

Will MATCH return a couple of numbers, representing row and columns?

Thank you,

stefano

Hello, Stefano,

no, MATCH will not return the numbers for both row and column. But depending on your task, you can try another way - use MATCH with INDEX.

Wow!!

by colum 1264012 - A0001264012

by colum 1264012 - A0001264012 how to match - 0

7/13/2017 1301311 ESI NDT 0936 PIT 2A - NMY 2A SARNO, L. #VALUE! 07/13/2017 A001301311 NTX 9035

Unless I am misunderstanding, I think the first example is wrongly explained. Match finds Laura in position 4 because she is the fourth item in the range being searched, not because that is her score ranking as stated. As it happens, she is fifth highest score, not fourth, after Rachael(1st with 287), Christian (2nd with 280), Brian (3rd with 274), Neal (4th - 240). But that's just chance as Match is not looking at the scores, only the names (the A2-A8 range). There is no "offset" to tell it to look at the scores.

In effect, unless you wanted to know where a student's name was positioned in a random list of names, I don't believe this example tells you anything else by itself?

Hi Paul,

That is a good catch! Yes, Match returns Laura's position in the range being searched. And because the scores are

sorted from largest to smallest, it is also her position among other students.For some reason, in my original screenshot, the highest score (Rachael's) appeared at the bottom of the list. Not sure how that could happen, maybe I added it after sorting the Score column. Anyway, I've resorted the column and updated the screenshot. Now, the Match formula returns the 5th position, exactly as it should. I've also added this explanation to the post to make the example clearer.

Thank you again for your feedback!

I have a problem where I need to extract a list of dates between 2 given dates from a vertical array of dates in ascending order. Is this possible using the index match functionality without resorting to VB. I'd rather avoid have blank entries at the top of the generated list too.

Hello, Chris,

supposing that you have the dates in A1:A24, the first given date - in B1 and the second - in B2, you can try the formula similar to the one below, but please keep in mind that it's an array formula and it should be entered by pressing Ctrl+Shift+Enter on your keyboard:

`{=IF(SUM(($A$1:$A$24*(A1>$B$1))*($A$1:$A$24*(A1< $B$2)))=0,"",A1)}`

I kindly ask you to alter it according to the way your data is stored.

If you still have some problems or the formula doesn't work, please send us the workbook with your data to support@ablebits.com . Don't forget to link this comment in your email.

We'll look into your task and try to help.

I have a slightly different problem which doesn't seem to be solved by Match because Match will only return the first value. I have a number of surveys done by a number of people on a series of days. Some people will have done the survey more than twice. How can I determine the date difference between each survey and the preceding one, please? When I apply match, index and datedif, only the difference between the latest and the first survey dates is returned. Any suggestions?

Hello,

For me to understand the problem better, please send me a small sample workbook with your source data and the result you expect to get to support@ablebits.com. Please don't worry if you have confidential information there, we never disclose the data we get from our customers and delete it as soon as the problem is resolved.

Please also don't forget to include the link to this comment into your email.

I'll look into your task and try to help.

if the same values are there in the both the values then i have to give condition like as "name" so please explain how to do it?

thanks

ramesh

I don't seem be able to use match when the values in the row being searched for a match are in TIME format. I'm trying to find the element that equals "11:38 PM", which is there, but my match formula returns #N/A, I think for a reason related to this. =MATCH("11:38 PM",A2:A12,0). That range does contain the time value. It must be something about indicating the value being sought.

I am trying to run an index that will look for a specific name in four different columns and if that name appears in any of those columns (or all of them), give me the info that is in the first column.

To do this, the match doesn't seem to work. Is there an or component that can used?

I am trying to find a better formula to look for a value using index and match. could you please help me to figure out the problem in the below formula. I am not getting the result. the result is "#N/A"

1. {=INDEX(BQ:BQ,MATCH(1,(VLOOKUP(LEFT(BF2,4),BL:BL,1,FALSE))*(BO:BO=D3),0))}

2. {=INDEX(BQ:BQ,MATCH(1,BL:BL=OR(BD2,BE2,BF2))*(BO:BO=D4),0)}

3. {=INDEX(BQ:BQ,MATCH(1,BL:BL=BH2&"*")*(BO:BO=D5),0)}

whereas below formula with single cell reference works fine..

4. {=INDEX(BQ:BQ,MATCH(1,(BL:BL=BC2)*(BO:BO=D6),0))}

Please help.

I have a large workbook with multiple tabs that all feed each other. Everything that is being fed into other sheets is currently done by linking to individual cells, which means that sorting does not work well. I'm looking for a solution that would allow me to use a unique identifier for each line item, feed info between sheets, and allow the individual sheets to all be sorted without affecting the data presented. Is this possible with INDEX/MATCH?