- How does XMATCH differ from the older MATCH function?
- XMATCH adds optional search_mode for reverse and binary searches, and it supports wildcard matching with match_mode = 2. It also returns the position of the next larger or smaller item, which MATCH cannot do without additional tricks.
- Can XMATCH perform a binary search on unsorted data?
- No. Binary search (search_mode = 2) requires the lookup_array to be sorted in ascending order for exact or next-larger matches, and descending order for next-smaller matches. Using it on unsorted data will produce incorrect results or a #NUM! error.
- What does the search_mode argument control?
- search_mode determines the direction and algorithm of the search: 1 scans from the first to the last element, -1 scans from the last to the first, and 2 performs a binary search on a sorted range, which is much faster for large datasets.
- Why does XMATCH return #N/A for a value that I see in the list?
- If the lookup_array contains hidden characters, leading/trailing spaces, or mismatched data types (e.g., number stored as text), XMATCH treats them as different values and returns #N/A. Clean the data with TRIM or VALUE, or use exact match_mode = 0 with appropriate type conversion.