Smart Systems for Home

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

XLOOKUP in Excel: Cara Pakai Langkah demi Langkah

· 6 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 and HLOOKUP: it looks up a value in one range and returns the matching value from another range in the same row (or column) — no column counting, so inserted columns never break your formula. Type =XLOOKUP(lookup_value, lookup_array, return_array) and press Enter. For example, =XLOOKUP(A2, D2:D100, E2:E100) finds the value in A2 inside the list D2:D100 and returns whatever sits beside it in E2:E100. That single line achieves most of what used to need two or three older functions.

What You'll Need

  • Excel for Microsoft 365, Excel 2021 or Excel 2024, on Windows, Mac, or in Excel for the web. XLOOKUP is not available in Excel 2019 or earlier — those versions throw a #NAME? error.
  • A lookup table with a unique identifier column (ID, SKU, name) and one or more columns of values you want to pull back.
  • The lookup range and the return range must be the same size and line up row for row. The easiest way is to select whole columns or a table, not hand-picked cells.

Step-by-Step

  1. Lay out your data cleanly. Put one header row on top and no blank rows or columns inside the data. A blank row in the middle of a lookup range is the most common cause of mysterious missing results.
  2. Click the cell where the result should appear. That is normally the cell right next to the lookup value you are searching from.
  3. Type =XLOOKUP( and notice the argument hints appear under the formula bar. Menu labels and function hints can differ slightly by version and region, but the argument order is stable.
  4. Enter the lookup value: click the cell holding the thing you are searching for, e.g. the invoice number in A2. Then type a comma.
  5. Enter the lookup array: the single column (or row) that contains the same identifiers in your source table. Click the header and drag down, or reference the whole column like Sheet2!A:A. Type a comma.
  6. Enter the return array: the column you want values back from, e.g. Sheet2!C:C. At this point you can type ) and press Enter — the remaining three arguments are optional.
  7. Copy the formula down. Because you used whole-column references, every row resolves independently. If you used a fixed block such as D2:D100, press F4 to make it absolute ($D$2:$D$100) before copying down, or use a table reference so Excel handles the expansion.
  8. Add the fourth argument for a friendly fallback: =XLOOKUP(A2, Sheet2!A:A, Sheet2!C:C, "Not found"). Without it, any miss shows #N/A.
  9. Choose a match mode with the fifth argument when you need it. The default 0 requires an exact match. Use -1 for an exact match or the next smaller item and 1 for exact or the next larger — useful for lookup tables such as price bands or tax brackets, where you search the start of each band.
  10. Set the search mode with the sixth argument. Default 1 searches first-to-last; -1 searches last-to-first, which returns the most recent entry when duplicates exist, such as the latest status update for a ticket.
  11. Test three cases before trusting the sheet: a value you know exists, a value you know does not exist, and a duplicate. Confirm the result matches what you expect each time.

Common Mistakes

  • Mismatched range sizes. If the lookup array is 99 rows and the return array is 100, XLOOKUP returns #VALUE!. Whole-column references avoid this entirely.
  • Numbers stored as text. An ID with a leading apostrophe or a trailing space will never match a real number. Trim spaces with TRIM and convert with VALUE, or clean the source data.
  • Forgotten fourth argument. Expecting a blank and getting #N/A sends people hunting for data that is present but slightly different.
  • Unsorted ranges with approximate mode. If you use -1 or 1 for approximate matching, the lookup column should be sorted ascending; otherwise the result can be wrong without any error.
  • Using XLOOKUP in a shared workbook with older Excel. Anyone on Excel 2019 or earlier sees #NAME?. Consider INDEX and MATCH if the file travels to older versions.
  • Duplicates ignored. XLOOKUP quietly returns the first (or last) match. It does not warn you, so broadly duplicated IDs can give plausible but wrong answers.

Tips

  • Return several columns at once by making the return array a multi-column range, then drag the formula across; each copied cell takes the next column.
  • XLOOKUP can search horizontally when the lookup array is a row, so the same function replaces HLOOKUP.
  • Save the common cases: =XLOOKUP(A2, Products[SKU], Products[Price], 0) with a table is self-expanding and readable.
  • For a two-way lookup, use XLOOKUP for the row and nest a second XLOOKUP for the column index, or nest XLOOKUP inside XLOOKUP so the inner call picks the column to return.
  • Format the result column with the same data type as the source (date, currency), otherwise you may be looking at the right number with the wrong display.
  • Use Excel's Evaluate Formula tool to step through the arguments when a formula returns something unexpected.

Troubleshooting

  • #NAME? Your Excel version does not support XLOOKUP, or the function name is misspelled. Check the version or switch to INDEX and MATCH: =INDEX(return, MATCH(value, lookup, 0)).
  • #N/A on a value you can see. Compare the two cells character by character; trailing spaces, non-printing characters, or a text-formatted number are the usual suspects. =A2=Sheet2!A5 tells you instantly whether they truly match.
  • #VALUE! The ranges differ in size. Re-select both with the same number of rows or switch to whole columns.
  • #REF! The return array was deleted, or a sheet it points to was removed. Repair the reference or re-point it to the current range.
  • Wrong value, no error. Check for duplicate IDs and decide whether you want first or last match, then set the search mode accordingly.
  • Formula copied down gives identical results. A range was locked with $ when it should be relative, or the lookup value reference itself was made absolute.
  • Everything looks fine but the file is slow. Whole-column XLOOKUP across many thousands of rows on volatile sheets adds up; limit ranges to the actual data or use a table.

Frequently Asked Questions

Does XLOOKUP work in older Excel versions?

No. It requires Microsoft 365, Excel 2021 or Excel 2024. Older versions return #NAME?, and INDEX with MATCH is the standard substitute.

What is the difference between XLOOKUP and VLOOKUP?

XLOOKUP searches any column and returns any column, has a built-in not-found argument, and does not need a column index number, so inserted columns cannot break it. VLOOKUP can only return columns to the right of the lookup column.

How do I return the last match instead of the first?

Set the sixth argument to -1: =XLOOKUP(A2, D:D, E:E, "", 0, -1) searches from the bottom up.

Can XLOOKUP return more than one column?

Yes. Point the return array at several columns, and each cell in the spilled or copied range picks up the next column in order.

Is XLOOKUP case-sensitive?

No, it is not case-sensitive by default. If case matters, combine it with EXACT-style logic, for example by comparing explicitly rather than relying on the lookup.

Why does my XLOOKUP return a number where I expected text?

The source cell itself is numeric. XLOOKUP returns the stored value, not a guess at formatting; change the format of the source or wrap the formula in TEXT to control the display.