Skip to content

MATCH

Returns the position of a value in a row or column. It is the partner of INDEX in the classic INDEX/MATCH lookup.

Syntax

=MATCH(, , )

Lookup and reference

Every version of Excel, including Microsoft 365, Excel 2024, 2021, 2019, 2016 and earlier, Excel for the web and the mobile apps.

Try it

Edit the formula in B9 or change the inputs. The sheet recalculates as you type.

B9
A
B
C
1
Item code
2
T-210
3
T-114
4
T-387
5
T-052
6
T-299
7
8
Find
Position
9
T-387
3

B9 =MATCH(A9,A2:A6,0) returns 3

How MATCH works

MATCH tells you where something is. Given a value and a single row or column, it returns the position of the value: 1 for the first item, 2 for the second, and so on. It returns a position, not the value itself, so it is usually paired with INDEX, which turns a position back into a value.

The arguments

  • lookup_value is what you are searching for.
  • lookup_array is one row or one column. The position counts from the start of that range, not from the top of the sheet. If the value is in A5 and the range is A3:A9, MATCH returns 3.
  • match_type sets the kind of match. This argument decides whether the formula is reliable, so set it every time.

The three match types

  • 0 is an exact match. Use it for IDs, names and codes. It returns the first match, ignores case, and accepts the wildcards *, ? and ~ when you look up text. If nothing matches, MATCH returns #N/A.
  • 1 is the default. It returns the position of the largest value that is less than or equal to lookup_value, and it expects the range sorted ascending. Use it for bands, such as a commission table that starts at each threshold.
  • -1 returns the position of the smallest value that is greater than or equal to lookup_value, and expects descending data. It is rarely needed.

Because 1 is the default, =MATCH(A9, A2:A20) runs an approximate match. On unsorted data it can return a wrong position without any error. Type the third argument every time.

INDEX/MATCH versus VLOOKUP and XLOOKUP

=INDEX(C2:C9, MATCH(A12, A2:A9, 0)) does what VLOOKUP does, but without counting columns and without the restriction that the answer must be right of the search column. It works in every version of Excel. XLOOKUP replaces the pair with one function and is easier to read, but it needs Excel 2021 or Microsoft 365. XMATCH is the modern version of MATCH, with an exact match by default and a search-from-the-end option.

MATCH is also useful on its own. =MATCH(B8, A1:H1, 0) finds which column a header is in, which you can feed to VLOOKUP as its column number. And =ISNUMBER(MATCH(A2, F:F, 0)) is a quick test for whether a value appears in another list.

Errors

#N/A means no match, or, with match types 1 and -1, data that isn't sorted in the way the type expects. Lookup values longer than 255 characters return #VALUE!. A number stored as text will not match a real number: 1043 won't find "1043".

Arguments

lookup_value
The value to find, such as A9. It can be a number, text or a logical value. Point at a cell rather than typing it.
lookup_array
The single row or column to search, such as A2:A20. A range that is several rows and several columns returns #N/A.
match_typeoptional
0 finds the first exact match. 1, the default when you leave it out, finds the largest value that is less than or equal to lookup_value and needs ascending data. -1 finds the smallest value that is greater than or equal to lookup_value and needs descending data.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Exact match: the position of a code in a list

B9 =MATCH(A9,A2:A6,0)

Result: 3

T-387 is the third item in A2:A6. The 0 asks for an exact match, which is what an unsorted list of codes needs.

B9
A
B
C
1
Item code
2
T-210
3
T-114
4
T-387
5
T-052
6
T-299
7
8
Find
Position
9
T-387
3

B9 =MATCH(A9,A2:A6,0) returns 3

Example 2

Approximate match: which band does a value fall in

B9 =MATCH(A9,A2:A6,1)

Result: 4

1,800 sits between 1,000 and 2,500, so MATCH returns the position of 1,000, which is 4. The thresholds are sorted ascending, as match type 1 requires.

B9
A
B
C
1
Order from
2
0
3
100
4
500
5
1,000
6
2,500
7
8
Order value
Band number
9
1,800
4

B9 =MATCH(A9,A2:A6,1) returns 4

Example 3

Wildcard: the first description that starts with some text

B9 =MATCH(A9&"*",A2:A6,0)

Result: 2

Joining * to the end of A9 makes the lookup value Gloves*, which matches any text that starts with Gloves. MATCH returns the first one, in position 2.

B9
A
B
C
1
Description
2
Safety goggles
3
Gloves, nitrile M
4
Gloves, leather L
5
Hi-vis vest
6
Hard hat
7
8
Starts with
Position
9
Gloves
2

B9 =MATCH(A9&"*",A2:A6,0) returns 2

Example 4

Find which column a header is in

B4 =MATCH(A4,A1:E1,0)

Result: 4

MATCH works on a row as well as a column. Q3 is the fourth header in A1:E1, counting Region as 1.

B4
A
B
C
D
E
F
1
Region
Q1
Q2
Q3
Q4
2
3
Quarter
Column
4
Q3
4
5

B4 =MATCH(A4,A1:E1,0) returns 4

Example 5

Position of the last number in a column

C2 =MATCH(9.99E+307,A2:A10)

Result: 5

9.99E+307 is larger than any number you will enter. An approximate match on it stops at the last number in the range, so the result is the count of rows up to the last entry. Blank cells below are ignored.

C2
A
B
C
1
Weekly sales
Last entry at row
2
410
5
3
385
4
462
5
498
6
455
7
8
9
10
11

C2 =MATCH(9.99E+307,A2:A10) returns 5

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 3

In B9, return the position of the item code in A9 within the Item code list.

Answer in B9.

B9
A
B
C
D
E
F
1
Item code
Description
Order from
2
T-210
Safety goggles
0
3
T-114
Gloves, nitrile M
100
4
T-387
Gloves, leather L
500
5
T-052
Hi-vis vest
1000
6
T-299
Ear defenders
2500
7
T-143
Hard hat
8
Find code
9
T-052
10
Gloves
11
Order value
12
640

Common mistakes

  • Leaving out match_type runs an approximate match (type 1). On unsorted data it returns a wrong position with no error. Type 0 for exact lookups.
  • The position counts from the start of lookup_array. If INDEX reads a range that starts on a different row than MATCH searched, the result is off by one. Start both ranges on the same row.
  • #N/A means nothing matched. Check for trailing spaces, a number stored as text, or data that isn't sorted when you use match type 1 or -1.
  • MATCH searches one row or one column. A two-dimensional range such as A2:C9 returns #N/A.
  • Wildcards only work with match type 0, and only on text. A lookup value that contains a real * or ? needs a ~ in front of it.

Questions people ask

What does MATCH return in Excel?

The position of the lookup value within the range you search, counting from 1. It doesn't return the value itself. Pair it with INDEX to fetch the value at that position.

What is the difference between MATCH 0, 1 and -1?

0 is an exact match on any data. 1 finds the largest value up to the lookup value and needs ascending data. -1 finds the smallest value from the lookup value upward and needs descending data. If you leave the argument out, you get 1.

Why does MATCH return #N/A?

Either the value isn't in the range, or the data isn't sorted the way match type 1 or -1 needs. Check for extra spaces and for numbers stored as text. Wrap the formula in IFNA to show your own message.

Is MATCH case-sensitive?

No. Looking up "east" finds "East". For a case-sensitive position, use `MATCH(TRUE, EXACT(A2:A9, A12), 0)`, which returns the position in current Excel.

Is MATCH replaced by XMATCH?

XMATCH is the newer version, with exact match by default and an option to search from the end. It needs Excel 2021 or Microsoft 365. MATCH still works everywhere, including Excel 2019 and earlier.

Learn MATCH in a real sheet.

MATCH is taught in Lookups and references, lesson 4: MATCH: finding a position. Each lesson is a short, graded exercise like the one above.