Excel’s XMATCH function replaces the need for VLOOKUP when you need to find an exact match in a list, and it’s much faster—especially in large datasets. It looks for the first position where a value matches and returns that index, rather than assuming the first column is always keys and others are data. You’ll need Excel 365, Excel 2021, Excel 2021 for Mac, or Excel 2019 with Office 365 updates (as of 2024), because earlier versions lack this feature.
What You'll Need
- Excel file with two columns: one for lookup values and one for matching entries.
- Excel 365, Excel 2021 (with updates), or Excel 2019 (Office 365) to use XMATCH (earlier versions require workarounds).
- Microsoft Excel reference for syntax (confirm your version’s exact wording).
- A simple, one-dimensional array—no multi-dimensional tables or nested ranges—in each lookup range.
Step-by-Step
- Prepare your data:
- Place your lookup values in a column (e.g., **A2:A10**).
- Place the matching entries in another column (e.g., **B2:B10**). If you need the returned index (position) of the match, keep the entries blank or leave a placeholder (e.g., 0).
- For example:
Lookup (A) Matches (B) Apple Fruit Banana Banana Carrot Vegetable Orange Citrus
- Enter the XMATCH formula in a new cell (e.g., **C2**) to return the position of the first match:
=XMATCH(A2, B$2:B$10, 0)- Reference 1 (lookup value):** `A2` (the cell you’re searching for, e.g., "Banana").
- Reference 2 (array to search):** `B$2:B$10` (the column with matching entries). Use absolute addressing (`$2:` or `$10`) if you drag the formula downward.
- Optional third argument (type of match):**
0(default) for exact matches (case-sensitive).1for approximate matches (e.g., partial text).
The result will be the row number of the first exact match. For "Banana" in the example, the formula returns **2** (since "Banana" is in row 2 of column B).
- Test your formula by entering values in **A2** and checking **C2**. For example:
A2 Result in C2 Apple 1 Orange 4 Mango #N/A (no match) - Drag the formula downward to apply it to all rows in the lookup column (e.g., **A2:A10**). If the lookup column has more rows, adjust the reference range in the formula (e.g., `B$2:$B$20`).
Common Mistakes
- Matching wrong columns: Ensure the lookup value and array are in the correct columns. For example, if your lookup is in **A** and matches in **C**, use `=XMATCH(A2, C$2:C$10, 0)`.
- Forgetting absolute references: If you drag the formula downward, replace `$2:` with `$2` or `$10` to lock the top-left cell (e.g., `=XMATCH(A2, C$2:$C$10, 0)`).
- Case sensitivity: By default, XMATCH is case-sensitive. To ignore case, use `=XMATCH(LOWER(A2), LOWER(B$2:B$10), 0)`.
- Array must be linear: XMATCH only works with one-dimensional arrays. If your data is in a table, transpose it or use nested functions like `INDEX(MATCH(...))` instead.
Tips
- Use wildcards for partial matches: Replace `0` with `1` to find matches that contain text (e.g., `=XMATCH(A2, B$2:B$10, 1)` searches for "ban" in "Banana").
- Cache results: If you’re doing repeated searches, use `=INDEX(B$2:B$10, XMATCH(A2, A$2:A$10, 0))` to return the actual match instead of just the index.
- Combine with VLOOKUP: If you need to match across multiple columns (e.g., a key in column A and a value in column C), use `=VLOOKUP(A2, {A$2:A$10, C$2:C$10}, 2, FALSE)`.
- Avoid #N/A errors: Ensure the lookup value exists in the array. If not, XMATCH returns `#N/A`. For partial matches, add a dynamic range (e.g., `=XMATCH(A2, B$2:$B$10, 1)`).
Troubleshooting
- Formula returns #N/A:
- Check if the lookup value exists in the array. If not, either add the value or adjust the third argument to `1` for partial matches.
- Verify the array is continuous and has no gaps (e.g., `B2:B10` should not skip rows).
- Ensure absolute references are used (e.g., `B$2:B$10`).
- Formula returns #VALUE!:
- This rarely happens unless you pass a non-numeric value to XMATCH. Double-check your data types (e.g., text vs. numbers).
- Slow performance on large datasets:
- Use volatile functions like XMATCH sparingly in large worksheets. Consider indexing or pivot tables for better speed.
- If possible, transpose your data into a linear format (e.g., use `=TRANSPOSE(...)`).
- Formula not updating:
- Restart Excel or refresh the worksheet. Ensure no other formulas are referencing the same cells.
- If using absolute references, verify they’re not accidentally locked (e.g., `F4` to convert to relative references).
Frequently Asked Questions
1. How does XMATCH differ from VLOOKUP?
XMATCH returns the position of the first match in a linear array, while VLOOKUP assumes the first column is always keys and returns the corresponding value. XMATCH is faster for exact matches and works with any column, whereas VLOOKUP is outdated and inflexible.
2. Can I use XMATCH with dates?
Yes, but ensure the dates are in a numeric format (e.g., serial numbers). If your dates are text, convert them to numbers first (e.g., `=DATE(YEAR(A2), MONTH(A2), DAY(A2))`).
3. How do I match case-insensitively?
Wrap both the lookup value and array in `LOWER()`: `=XMATCH(LOWER(A2), LOWER(B$2:B$10), 0)`.
4. What happens if there are multiple matches?
XMATCH returns the first position where the value matches. If you need all matches, use a loop or `FILTER` (Excel 365) with a custom array:
=FILTER(B$2:B$10, (A$2:A$10)=A2)
5. Can XMATCH work with arrays in a table?
No. XMATCH requires a linear array. If your data is in a table, transpose it or use `INDEX` with `MATCH`:
=INDEX(Table1[Column2], MATCH(A2, Table1[Column1], 0))
6. Why is XMATCH slower than expected?
This could be due to other volatile functions in the same worksheet or dataset size exceeding Excel’s performance limits. Try:
- Using `INDEX` with `MATCH` for static data.
- Caching results in a helper column.
- Simplifying the formula (e.g., avoid nested functions).