If you work with reports, you look things up all day: a price for a product code, a manager for an employee ID, a region for a customer. For years, VLOOKUP was the answer. Newer versions of Excel give you XLOOKUP, which is simpler and safer. Here is what changes.
The syntax side by side
=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
Example: find the price of the product code in A2.
=VLOOKUP(A2, Products!A:D, 4, FALSE)
=XLOOKUP(A2, Products!A:A, Products!D:D, "Not found")
5 reasons XLOOKUP is better
- Exact match by default. VLOOKUP does an approximate match unless you type FALSE (or 0) at the end, a classic source of wrong numbers. XLOOKUP looks for an exact match unless you ask otherwise.
- It can look left. VLOOKUP only returns values to the right of the lookup column. XLOOKUP takes separate lookup and return ranges, so the result can be on either side.
- Inserting columns does not break it. VLOOKUP uses a column number (4 in the example). Insert a column in the table and the formula quietly returns the wrong field. XLOOKUP points at the actual return column.
- Built-in "not found" message. The fourth argument replaces the #N/A error, so you no longer need to wrap the formula in IFERROR.
- Search from the bottom. Set search_mode to -1 to find the last match, for example the latest transaction for a customer.
When VLOOKUP still makes sense
XLOOKUP is available in Excel for Microsoft 365, Excel 2021 and later, and Excel for the web. Google Sheets has it too. If your file will be opened in Excel 2019 or older, XLOOKUP shows a #NAME? error there, so stay with VLOOKUP, or use the classic INDEX + MATCH pair, which also looks left:
=INDEX(Products!D:D, MATCH(A2, Products!A:A, 0))
Quick tip
Turn your data into a table first (Ctrl + T). Then your formula can use names instead of ranges, such as =XLOOKUP(A2, Products[Code], Products[Price], "Not found"), and it grows automatically when new rows are added.
