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 =MATCH(A9,A2:A6,0) returns 3
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(, , )
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 =MATCH(A9,A2:A6,0) returns 3
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.
*, ? and ~ when you look up text. If nothing matches, MATCH returns #N/A.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(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.
#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".
A9. It can be a number, text or a logical value. Point at a cell rather than typing it.A2:A20. A range that is several rows and several columns returns #N/A.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.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
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 =MATCH(A9,A2:A6,0) returns 3
Example 2
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 =MATCH(A9,A2:A6,1) returns 4
Example 3
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 =MATCH(A9&"*",A2:A6,0) returns 2
Example 4
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 =MATCH(A4,A1:E1,0) returns 4
Example 5
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 =MATCH(9.99E+307,A2:A10) returns 5
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.
0 for exact lookups.#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.A2:C9 returns #N/A.* or ? needs a ~ in front of it.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.
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.
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.
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.
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.
MATCH is taught in Lookups and references, lesson 4: MATCH: finding a position. Each lesson is a short, graded exercise like the one above.