Sub topic 13
Compatibility and Comparison with VLOOKUP and INDEX/MATCH
This chapter assumes you can write XLOOKUP formulas with all six arguments, including match_mode and search_mode. It also assumes you know basic VLOOKUP, because the comparisons below translate between the functions. The goal is practical. You will learn how to convert existing formulas, decide which function fits a workbook, and avoid compatibility problems when files are shared.
Where XLOOKUP runs and where it does not
XLOOKUP is available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. It is not in Excel 2019, Excel 2016 or earlier. Other spreadsheet programs are mixed. Google Sheets supports it, and recent LibreOffice versions have added it. Check the version your colleagues use before relying on it.
If you send a workbook containing XLOOKUP to someone with Excel 2019, their copy cannot calculate the function. The formula appears with a prefix, such as =_xlfn.XLOOKUP(...), and any recalculation returns #NAME?. Cached results may display until the workbook recalculates, so the problem can look intermittent.
Translating VLOOKUP to XLOOKUP
A VLOOKUP formula has four arguments: the lookup value, a table, a column number, and a match type. XLOOKUP replaces the table and column number with two separate ranges. This is the most important structural difference.
=VLOOKUP(E2, A2:D10, 3, FALSE)=XLOOKUP(E2, A2:A10, C2:C10)Both formulas look for the value in E2 in column A and return the value from column C. The XLOOKUP version points directly at the column to return, so it has no hard-coded 3.
Differences in behavior
- Default match type. VLOOKUP defaults to approximate matching when you omit the fourth argument. Forgetting
FALSEis a common source of wrong results that look plausible. XLOOKUP defaults to exact matching. - Column numbers. If someone inserts a column between A and C in the VLOOKUP table, the
3points at the wrong column. XLOOKUP's ranges adjust automatically, like any other cell reference. - Lookup direction. VLOOKUP searches only the leftmost column of the table and returns values to its right. XLOOKUP can return a column to the left of the lookup column, and it works on rows as well as columns.
- Missing values. VLOOKUP returns
#N/A, and you wrap it inIFNAorIFERROR. XLOOKUP has theif_not_foundargument built in. - Range sizes. The lookup array and return array of an XLOOKUP must have the same number of rows (or columns). A mismatch gives
#VALUE!. VLOOKUP has no such check because it uses one table.
Approximate matches
VLOOKUP's approximate mode requires the first column sorted ascending and returns the largest value less than or equal to the lookup value. The XLOOKUP equivalent uses match_mode -1.
=VLOOKUP(B2, $E$2:$F$6, 2, TRUE)=XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6, "Below minimum", -1)The XLOOKUP version has two advantages. It does not require sorted data when you use the default linear search. It also lets you handle scores below the lowest bound with text instead of #N/A.
Translating INDEX/MATCH to XLOOKUP
INDEX/MATCH has been the standard workaround for VLOOKUP's limits. MATCH finds the position of the lookup value, and INDEX returns the item at that position in another range.
=INDEX(C2:C10, MATCH(E2, A2:A10, 0))=XLOOKUP(E2, A2:A10, C2:C10)The two formulas return the same result. XLOOKUP combines both steps and removes the easy-to-forget 0 that makes MATCH exact.
The sign convention differs
MATCH and XLOOKUP use opposite numbers for approximate matching, which causes errors when converting formulas.
| Goal | MATCH `match_type` | XLOOKUP `match_mode` |
|---|---|---|
| Exact match only | 0 | 0 |
| Exact or next smaller | 1 | -1 |
| Exact or next larger | -1 | 1 |
In MATCH, 1 means "largest value that is less than or equal to," and it needs ascending data. In XLOOKUP, -1 gives the same result. Copying the number across without changing the sign gives the opposite result: the next larger value instead of the next smaller one.
Here is the grade lookup written both ways:
=INDEX($F$2:$F$6, MATCH(B2, $E$2:$E$6, 1))=XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6, "Below minimum", -1)Returning a whole row
INDEX/MATCH can return several columns by passing 0 as the column argument.
=INDEX(B2:D10, MATCH(E2, A2:A10, 0), 0)The XLOOKUP equivalent is the multi-column return from earlier in this tutorial:
=XLOOKUP(E2, A2:A10, B2:D10)Both spill the row's values across adjacent cells in a version of Excel that supports dynamic arrays.
Features only XLOOKUP offers directly
Some tasks that take extra work with the older functions are single arguments in XLOOKUP.
| Task | VLOOKUP | INDEX/MATCH | XLOOKUP |
|---|---|---|---|
| Return the last match | Not possible | Workaround needed | `search_mode` -1 |
| Wildcard matching | Works with `FALSE` | Works with match type 0 | `match_mode` 2 |
| Custom text for missing values | Wrap in IFNA | Wrap in IFNA | `if_not_found` |
| Next larger value | Not possible | Needs sorted descending data and match type -1 | `match_mode` 1 |
| Lookup to the left | Not possible | Works | Works |
| Binary search | Sorted data and approximate mode only | Sorted data and match type 1 or -1 | `search_mode` 2 or -2 |
The last-match case is the clearest example. With INDEX/MATCH you need a trick based on LOOKUP:
=LOOKUP(2, 1/(A2:A100=E2), C2:C100)The XLOOKUP version says what it does:
=XLOOKUP(E2, A2:A100, C2:C100, "None", 0, -1)Choosing between them
Use these criteria in practice:
- Version support comes first. If anyone on an older version must recalculate the file, use a function that version supports.
- Prefer XLOOKUP for new work in a modern environment. It is shorter, defaults to exact matching, and is easier to read and audit.
- Do not convert working formulas without a reason. A VLOOKUP formula with
FALSEand a stable table layout is correct. Rewriting hundreds of them adds risk and no new result. - Convert formulas that are fragile. VLOOKUP formulas with hard-coded column numbers in tables that people edit are good candidates. So are formulas that depend on an omitted fourth argument.
Gotchas when converting
- Check the data types. Converting does not fix text-versus-number mismatches. A number stored as text still gives
#N/Ain all three functions. - Watch for the default match type in old formulas. A VLOOKUP written without
FALSEmay have been returning approximate matches. An XLOOKUP replacement is exact, so results can change, and the new answer may be the right one. - Mind the spill. An XLOOKUP that returns several columns needs empty cells to its right. If something blocks the spill, Excel returns
#SPILL!. - Test missing values.
if_not_foundonly replaces the "no match" case. An#N/Acoming from elsewhere, such as an error inside the return range, is not masked.IFNAwrapped around the whole formula catches every#N/A, which can hide real problems. - Do not mix whole tables and single columns. When converting, the lookup array and return array must be the same size, such as
A2:A10andC2:C10. Do not passA2:D10as the lookup array.
Summary
XLOOKUP replaces most VLOOKUP and INDEX/MATCH use. It uses direct ranges instead of column numbers, defaults to exact matching, has built-in handling for missing values, and supports last-to-first searching. Its approximate-match signs are reversed relative to MATCH. The cost is compatibility. It does not run in Excel 2019 or earlier, so the audience for the file should decide your choice.
Exercise
A colleague's VLOOKUP is =VLOOKUP(B2, $E$2:$F$6, 2) and returns grades from a bounds table. You convert it to =XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6) and several scores now return #N/A. What went wrong, and how do you fix it so the new formula matches the old one?
Show answer
The original VLOOKUP omitted the fourth argument, so it used approximate matching. XLOOKUP defaults to exact matching, so any score that is not exactly a bound returns #N/A. Add match_mode -1: =XLOOKUP(B2, $E$2:$E$6, $F$2:$F$6, "Below minimum", -1). The text in the fourth argument also replaces the #N/A that VLOOKUP would return for scores below the lowest bound.
Exercise
You have =INDEX(C2:C20, MATCH(E2, A2:A20, -1)) on data sorted in descending order, returning the smallest value that is greater than or equal to E2. Write the XLOOKUP equivalent and name one advantage it has.
Show answer
=XLOOKUP(E2, A2:A20, C2:C20, "Above range", 1). MATCH's -1 becomes XLOOKUP's 1 because the sign convention is reversed. One advantage is that the XLOOKUP formula does not require the data to be sorted when it uses the default linear search. Another is that it has a built-in missing-value argument.