The MATCH function in Google Sheets is a powerful tool that helps users locate the position of a specific value within a designated range. By returning the relative index of an item, it allows for efficient data retrieval and analysis, making it an essential component of many spreadsheet tasks.
Syntax
MATCH(search_key, range, [search_type])
- search_key: The value to search for in the specified range.
- range: The array or range of cells in which to search for the search_key.
- search_type: Optional. This determines whether the function looks for an exact match or an approximate match. Use 1 for approximate match (assumes the range is sorted in ascending order), 0 for an exact match, and -1 for an approximate match (assumes the range is sorted in descending order).
Example #1
MATCH("Apple", A1:A5, 0)
This function searches for the exact position of “Apple” in the range A1:A5. If “Apple” is in cell A3, the result will be 3.
Example #2
MATCH(25, B1:B10, 1)
This function looks for the approximate position of the number 25 in the range B1:B10, assuming the range is sorted in ascending order. If the closest number is 23 (in position 5), the result will be 5.
Example #3
MATCH("Banana", C1:C7, -1)
This example searches for “Banana” in the range C1:C7 using an approximate match with a descending order. If “Banana” is found in the second position, the result will be 2.
Error handling
- N/A: This error occurs when the search_key is not found in the specified range.
- VALUE!: This error arises when the data types in the search_key and range do not match or if the range is malformed.
- REF!: This error indicates that the specified range is invalid or references a deleted cell.