Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Run XLOOKUP in Excel: Step-by-Step Guide

· 7 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

XLOOKUP is Excel's modern replacement for VLOOKUP, HLOOKUP and the INDEX/MATCH pairing, and running it takes one formula with three core arguments: =XLOOKUP(lookup_value, lookup_array, return_array). You point it at the value you want to find, the column or row that contains that value, and the column or row holding the answer, and it returns the answer from the same position in the return range. Unlike older lookup functions it searches in any direction, does not need a column count, and returns an exact match by default, so the most common lookup mistakes simply do not happen.

The catch is availability: XLOOKUP exists in Excel for Microsoft 365, Excel 2021 and later, and the web and mobile versions of Excel. In Excel 2019 and older versions it returns #NAME? because the function does not exist there. If you see that error on a file you know works, the first thing to check is the version of Excel on the machine, not the formula.

What You'll Need

  • A version of Excel that includes XLOOKUP: Microsoft 365, Excel 2021 or newer, or Excel for the web or mobile. Excel 2019, 2016 and earlier do not have it.
  • A worksheet with the lookup value in one range and the data you want to return in another. The two ranges should be the same size, or at least line up row-for-row.
  • A lookup value that appears in the lookup range and is typed the same way, particularly for text: trailing spaces and a mix of text and numbers are the usual culprits when a match seems impossible.
  • No merged cells inside either range. Merged cells cause XLOOKUP to return unexpected results or errors.

Step-by-Step

  1. Click the cell where the result should appear. This is your result cell, separate from the table you are searching.
  2. Type =XLOOKUP(. As you type, Excel's formula autocomplete shows the argument list. If XLOOKUP does not appear in the list at all, stop here: the version of Excel you are using does not support it. Confirm the formula name is spelled with no spaces.
  3. Enter the lookup value. Click the cell holding the thing you want to find, for example a product code typed into A2. This is the first argument: =XLOOKUP(A2, ). You can also type a literal value, such as "Widget-100" in quotes, but a cell reference is easier to change later.
  4. Enter the lookup array (the search column). Select the entire column or range in your data table that contains the values you are searching through, for example $D$2:$D$500. Do not include the header row; if the header is included, XLOOKUP still works for exact matches but a header text value can be found by accident. This is the second argument: =XLOOKUP(A2, $D$2:$D$500, ).
  5. Enter the return array (the answer column). Select the range holding the values you want back, for example $F$2:$F$500. It should be the same height as the lookup array. If it is a different height, XLOOKUP returns a #VALUE! error. This completes the minimum formula: =XLOOKUP(A2, $D$2:$D$500, $F$2:$F$500).
  6. Press Enter. Excel returns the value from the return array at the same position where the lookup value was found. If the value is not present and you left the fourth argument empty, you get #N/A.
  7. Add a friendly not-found message (optional but recommended). Add a fourth argument: =XLOOKUP(A2, $D$2:$D$500, $F$2:$F$500, "Not found"). This shows your text instead of #N/A when there is no match, which is much easier for readers of the sheet to interpret.
  8. Copy the formula down. Drag the fill handle from the corner of the result cell down the required rows, or copy and paste. Because the lookup and return arrays are absolute references (dollar signs), each row looks up its own value correctly while searching the whole table.
  9. Return several columns at once (optional). XLOOKUP can return a whole block. If you give a return array spanning several columns, such as $F$2:$H$500, and you have a modern dynamic-array version of Excel, Excel spills the values across neighbouring cells. On older versions, you can use the same formula with a single column of the return array and copy it sideways if the arrays were built with relative column references.
  10. Do a manual check. Pick three known lookup values at random and compare the returned result against the source table by eye. This catches off-by-one errors from selecting the wrong range far more reliably than scanning for error codes.

Common Mistakes

Ranges of different heights. The lookup array and return array must be the same number of rows. Selecting one column from row 2 to 500 and the other from row 2 to 400 guarantees a #VALUE! error.

Including headers inconsistently. If one range starts at row 1 and the other at row 2, results shift by one row. Keep both ranges aligned to exactly the same start and end rows.

Expecting a partial match by default. XLOOKUP's fifth argument is match mode, and the default is exact match. To find a value that merely contains your search text, you need wildcards: =XLOOKUP("*"&A2&"*", $D$2:$D$500, $F$2:$F$500, "Not found", 2), where 2 enables wildcard matching.

Text versus numbers. A lookup value stored as text, such as '12345 with an apostrophe, will not match a number 12345 in the table. This is the single most frequent cause of an unexplained #N/A.

Forgetting the search mode argument order. The optional arguments go in this order: if_not_found, match_mode, search_mode. Putting a number in the fourth position when you meant match mode changes the meaning of the formula.

Tips

Use whole structural references such as D:D and F:F if you add rows often, but be aware that whole-column references can slow a very large workbook. Named ranges (Formulas > Define Name) make formulas readable and reduce range errors. To search from the last row upward instead of the first, add 6 as the search mode: =XLOOKUP(A2, $D$2:$D$500, $F$2:$F$500, "Not found", 0, -1) searches bottom-to-top, which is useful for finding the most recent entry. If you must share a file with people on Excel 2019, keep a VLOOKUP or INDEX/MATCH version as a fallback, because XLOOKUP formulas will break for them.

Menu and function labels can differ slightly by Excel version, device and region, and the mobile apps offer a cut-down formula experience; if the autocomplete does not show an optional argument, type the comma and argument anyway, since the function signature is the same.

Troubleshooting

#NAME? appears. The version of Excel does not support XLOOKUP, or the function name is mistyped. Check the version under File > Account and update Office if a newer build is available. If your organisation controls the installation, the update may need to come from IT.

#N/A appears for a value you can see. Check for extra spaces using =TRIM(A2) and compare the two cells with =A2=D2; if it returns FALSE, one is text and the other is a number. Converting the column to the same type with Text to Columns or a multiplication by 1 fixes it. Also confirm the value is inside the selected lookup range; it may sit in a row you did not include.

#VALUE! appears. Your two ranges are different sizes, or the return array is a shape XLOOKUP cannot align with the lookup array. Reselect both ranges from the same first row to the same last row.

The result is from the wrong row. You almost certainly did not lock the ranges with dollar signs, so copying down shifted the lookup range. Press F4 while editing the range to cycle to absolute references, then recopy.

Wrong value returned for a duplicate entry. When the lookup value appears more than once, XLOOKUP returns the first match found (or the last, if search mode is set to -1). Decide intentionally which one you want, or remove the duplicates.

Still stuck. Go to Formulas > Evaluate Formula and step through the calculation cell by cell. It shows exactly which range is being searched and why the match failed, which is usually faster than rebuilding the formula from scratch.

Frequently Asked Questions

Is XLOOKUP better than VLOOKUP?

For most purposes, yes. It searches left or right, defaults to exact matching, needs no column number, and can return a custom not-found message. VLOOKUP remains necessary only for older Excel versions and files shared with them.

Can XLOOKUP search to the left?

Yes. Simply select the lookup column to the right of the return column. There is no direction restriction, which is the main reason it replaces the INDEX/MATCH combination.

How do I return multiple columns at once?

Give XLOOKUP a return array that spans several columns, such as $F$2:$H$500. In dynamic-array versions of Excel, the results spill across the adjacent cells automatically; leave those cells empty so the spill is not blocked by #SPILL!.

Why does XLOOKUP show #N/A when the value exists?

Nearly always a text-versus-number mismatch or hidden spaces. Test with a direct comparison like =A2=D2 and clean the data with TRIM or a conversion step.

Does XLOOKUP work in Google Sheets or LibreOffice?

Google Sheets includes an XLOOKUP function, but its optional arguments may behave slightly differently from Excel's. LibreOffice Calc support varies by version, so check the current documentation before relying on a shared spreadsheet.

Can I use XLOOKUP to find the closest match?

Yes. Set the fifth argument to -1 for an exact match or the next smaller item, or 1 for an exact match or the next larger item. This is handy for tax brackets and tiered pricing, and the lookup range should be sorted for predictable results.