# XMATCH

## Content

XMATCH function searches for a specific item in an array or a range of cells and then returns the relative position of the item. In other words, this function can be used to find the position of an item in a list.
XMATCH function provides support for approximate matching, partial matching (using wildcard characters like "\*", "?" etc.), and exact matching.

## Syntax

`XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])`

## Arguments

This function has the following arguments:

| Argument | Description |
| -------- | ----------- |
| *lookup\_value* | [Required] Refers to the lookup value. |
| *lookup\_array* | [Required] Refers to the lookup array or cell range that you want to search. |
| *[match\_mode]* | [Optional] Specifies the type of the match as per the following values:<br>0 - Refers to exact match. If no matches are found, then the #N/A error is returned. This is the default match mode.<br>-1 - Refers to exact match. If no matches are found, then the next smaller item is returned.<br>1 - Refers to exact match. If no matches are found, then the next larger item is returned.<br>2 - Refers to a wildcard match where "\*", "?" and "\~" characters possess special meanings to indicate a partial match. |
| *[search\_mode]* | [Optional] Specifies the mode of the search as per the following values:<br>0 - Refers to the "search all" mode where all the matched values will be returned. [This mode is not available in Excel.]<br>1 - Refers to a search that starts at the first item. This is the default search mode.<br>-1 - Refers to a reverse search that starts at the last item.<br>2 - Refers to a binary search that depends upon the *lookup\_array* argument being sorted in ascending order.<br>-2 - Refers to a binary search that depends upon the *lookup\_array* argument being sorted in descending order. |

## Remarks

The XMATCH function can work with both vertical and horizontal arrays. This function returns the #N/A error if the lookup value is not found. XMATCH will return #VALUE! if using wildcard match mode and binary search mode at the same time.

## Examples

`XMATCH(G4,A5:A9)`
`XMATCH({5,4,1},C5:C9)`