What the video covers
The video introduces Excel’s XMATCH formula and explains exact matches, approximate matches, and searching from the bottom of a list. The worked example below uses a small range with a duplicate so you can see what each option changes.
Watch the video on YouTubeStep-by-step instructions
- Set up the example.
In a blank worksheet, enter Item ID in A1. Put 1001, 1008, 1005, and 1008 in A2 through A5, in that order. Type 1008 in C2. Keep all five values as numbers. - Find the first exact match.
In D2, enter=XMATCH(C2,A2:A5,0,1). Excel returns 2 because the first 1008 is the second entry in A2:A5. The cell that contains it is A3. - Find the last exact match.
In D3, enter=XMATCH(C2,A2:A5,0,-1). It returns 4 because the reverse search starts at A5. The position is still counted from the start of the original range. - Try a nearby-value match.
Put 1006 in C3. In D4, enter=XMATCH(C3,A2:A5,-1)to find an exact value or the next smaller one. It returns 3 for 1005. Leave this option off when different item IDs must always be treated as different items.
Watch the video
Play tutorial
Why it matters
XMATCH gives you a position within the selected range. That makes it useful with INDEX if you need a value from a corresponding row. Keep the lookup range and the INDEX return range aligned so their first entries refer to the same record.
Use exact matching for identifiers such as order numbers or SKUs. For threshold data where a nearby value has a defined meaning, choose whether you need the next smaller or next larger value. If you use XMATCH’s binary search modes later, sort the range in the direction that mode requires.
Check your result
The example should return 2 in D2, 4 in D3, and 3 in D4. Change C2 to 1001 and check that both exact formulas return 1. Change it to 1010 and the exact formulas should show #N/A.
Troubleshooting
If an exact match returns #N/A unexpectedly, check that the lookup value and source entries have the same type. Imported IDs may look like numbers while being stored as text. For text IDs, also inspect leading or trailing spaces. If Excel returns #NAME?, check that your edition supports XMATCH. Microsoft lists Microsoft 365, Excel for the web, and Excel 2021 or 2024.