How to Use the MATCH Function in Google Sheets | Find the Position of a Value in a Range
How to Use the MATCH Function
The MATCH function returns a number representing the relative position (counting from the start) of a specified search value within a cell range. In addition to finding rankings or positions on its own, it is frequently combined with the INDEX function for flexible data lookups.
Syntax
=MATCH(search_key, range, [search_type])
- search_key: The value or cell reference whose position you want to find (required).
- range: A one-dimensional range (1 column or 1 row) to search (required).
- search_type: Specifies how to match (defaults to
1if omitted):0: Exact match (no sorting required; usually recommended)1: Finds the largest value less than or equal tosearch_key(rangemust be sorted in ascending order)-1: Finds the smallest value greater than or equal tosearch_key(rangemust be sorted in descending order)
Table Example
Here is an example of finding which position (rank) from the top a specific page title appears in the page-view ranking table below.
| Row | Column A (Page Title) | Column B (Page Views) |
|---|---|---|
| 1 | Page Title | Page Views |
| 2 | Home Page | 15,200 |
| 3 | Pricing Plans | 8,400 |
| 4 | Contact Us | 3,100 |
| 5 | About Us | 1,900 |
- Formula:
=MATCH("Contact Us", A2:A5, 0) - Explanation: Counting from the start (
A2) ofA2:A5,"Contact Us"is in the 3rd position. - Result:
3
By combining this with INDEX as =INDEX(B2:B5, MATCH("Contact Us", A2:A5, 0)), you can dynamically retrieve the 3rd row’s page views (3,100).
Common Errors and Notes
- Search key not found or 2D range (
#N/Aerror): An#N/Aerror occurs ifsearch_keydoes not exist inrange, or if you pass a 2D range (both multiple rows and multiple columns) likeA2:B5. - Forgetting
0as the 3rd argument: If you omit the 3rd argument, as in=MATCH("Contact Us", A2:A5), it defaults to1(ascending search) and will return a completely wrong number when the data is not sorted alphabetically or numerically. Always specify0for exact matches. - Behavior with duplicate values: If the same value appears multiple times in
range,MATCHreturns the position of the first occurrence (topmost or leftmost).
Frequently Asked Questions
Q. What should I specify for the 3rd argument (search_type) in MATCH?
A. When looking up the position of an exact match, always specify "0". If omitted, it defaults to "1 (approximate match assuming ascending order)", which returns an incorrect position if the list is not sorted.
Q. Can MATCH search an entire multi-row, multi-column table at once?
A. No, the search range for MATCH must be a one-dimensional range—either a "single column (vertical)" or a "single row (horizontal)". Passing a multi-row by multi-column range causes an #N/A error.