Match
MATCH Function¶
The MATCH function in Excel searches for a specified value in a range and returns the relative position of that item within the range. It's commonly used to locate the position of a specific value in a row, column, or table.
Syntax:¶
MATCH(lookup_value, lookup_array, [match_type])
- lookup_value: The value that you want to search for.
- lookup_array: The range of cells containing possible matches. This range can be a row, a column, or a one-dimensional array.
- match_type (optional):
1or omitted:MATCHfinds the largest value less than or equal tolookup_value.lookup_arraymust be sorted in ascending order.0:MATCHfinds the first value exactly equal tolookup_value.lookup_arraydoes not need to be sorted.-1:MATCHfinds the smallest value greater than or equal tolookup_value.lookup_arraymust be sorted in descending order.
Examples:¶
=MATCH(9, A1:A10, 0)would search for the value9in the rangeA1:A10and return its relative position if it finds an exact match.=MATCH("Apple", B1:B5, 0)would search for the text "Apple" in the rangeB1:B5and return the position of "Apple" within that range.=MATCH(15, C1:C10, 1)assumingC1:C10is sorted in ascending order, would find the largest value less than or equal to 15.
Examples using Excel arrays:¶
=MATCH(3, {1,2,3,4,5}, 0)searches for3in the horizontal array{1,2,3,4,5}and returns3because3is the third element.=MATCH("B", {"A";"B";"C"}, 0)searches for"B"in the vertical array{"A";"B";"C"}and returns2because"B"is the second element.=MATCH(2.5, {1,2,3,4}, 1)returns2, because2is the largest value less than or equal to2.5in the array.
Note: When using arrays: {1,2,3,4} instead of cell ranges: C1:C10 no tables are created. arrays will allow MATCH to run in WASM
Usage Notes:¶
MATCHis frequently used with theINDEXfunction to retrieve a value at a found position.- The function is case-insensitive, meaning it does not distinguish between uppercase and lowercase when matching text.
- If
MATCHdoes not find a value, it returns the#N/Aerror.
Note: Choosing the correct
match_typeis crucial for getting the expected results.Note: When match type is 1 or -1, Codcel will automatically order the lookup_array correctly. This may give different results to Excel, if the lookup_array is not ordered correctly in Excel.
Note: The lookup_array must not contain functions, if it does the match may not work correctly.