How-to recipes · Lookups

How to look up a value to the left in Excel

VLOOKUP cannot return a column to the left of the search column. Use XLOOKUP in Microsoft 365 or INDEX and MATCH in Excel 2016 and 2019.

Beginner XLOOKUP INDEX MATCH VLOOKUP CHOOSE XMATCH

Your product list has the code in column A, the name in column B and the price in column C. Someone gives you a product name and asks for its code. VLOOKUP is stuck: it always searches the first column of the range and can only return columns to its right. Rearranging the columns is often not an option because other formulas or reports depend on the layout. This recipe shows how to look up to the left without moving any data.

The example data

Five products in A1:C6. The product name to look up is in F1, and we want its code in F2. The answer for Monitor is P-103.

Microsoft 365 and Excel 2021: XLOOKUP

XLOOKUP has separate arguments for the column you search and the column you return, so direction does not matter:

F2fx=XLOOKUP(F1,B2:B6,A2:A6,"Not found")
ABCDEF
1CodeProductPriceProductMonitor
2P-101Keyboard25CodeP-103
3P-102Mouse12
4P-103Monitor189
5P-104Laptop950
6P-105Dock145

XLOOKUP finds Monitor in B4 and returns the cell in the same position of A2:A6.

Result: P-103

  • F1: the value to find, here Monitor.
  • B2:B6: the column to search.
  • A2:A6: the column to return from. It can be left or right of the search column, or even on another sheet, as long as it has the same number of rows.
  • "Not found": shown instead of #N/A when the name is missing.

XLOOKUP matches exactly by default, so you do not need the FALSE that VLOOKUP requires.

Excel 2016 and 2019: INDEX and MATCH

In versions without XLOOKUP, combine MATCH, which finds the position of the name, with INDEX, which returns the value at that position of another column:

F2fx=INDEX(A2:A6,MATCH(F1,B2:B6,0))
ABCDEF
1CodeProductPriceProductMonitor
2P-101Keyboard25CodeP-103
3P-102Mouse12
4P-103Monitor189
5P-104Laptop950
6P-105Dock145

MATCH returns 3 (Monitor is the third product); INDEX returns the third code.

Result: P-103

  1. MATCH(F1,B2:B6,0) looks for Monitor in B2:B6. The 0 means exact match. The result is 3.
  2. INDEX(A2:A6,3) returns the 3rd cell of A2:A6, which is P-103.

INDEX/MATCH works in every Excel version, does not care about column order, and is not broken by inserting columns, because it uses ranges instead of a column number. To show a message instead of #N/A when nothing is found, wrap it: =IFERROR(INDEX(A2:A6,MATCH(F1,B2:B6,0)),"Not found").

The old VLOOKUP + CHOOSE trick

You may meet this formula in older workbooks:

Formula
=VLOOKUP(F1,CHOOSE({1,2},B2:B6,A2:A6),2,FALSE)

CHOOSE with the array {1,2} builds a virtual two-column table in memory with the names first and the codes second, so VLOOKUP can search the first column and return the second. It works, but it is hard to read, slower on big data and confusing for the next person. Prefer INDEX/MATCH or XLOOKUP and replace this pattern when you maintain such a workbook.

Return several columns at once

In Microsoft 365 XLOOKUP can return a whole row of results. If the table had more columns to the left, =XLOOKUP(F1,D2:D6,A2:C6) would spill code, name and price side by side. In Excel 2016 use one INDEX/MATCH per column, or put the MATCH in a helper cell and reference it from several INDEX formulas, which also makes the workbook faster because the search runs only once.

Pitfalls

  • Both ranges must have the same size. XLOOKUP(F1,B2:B6,A2:A7) returns #VALUE!, and INDEX/MATCH with mismatched ranges returns the wrong row without any warning.
  • Forgetting the 0 in MATCH switches it to approximate match, which needs sorted data and returns wrong codes on unsorted lists.
  • If two products have the same name, both formulas return the first one found. XLOOKUP can search from the bottom with search_mode -1.
  • Lock the ranges with $ ($B$2:$B$6) before copying the formula down to other rows; see Cell references: relative, absolute and mixed.
Tip. XMATCH is the modern version of MATCH in Microsoft 365 and works the same way inside INDEX. The complete comparison of lookup methods is in Lookup guide: VLOOKUP vs INDEX/MATCH vs XLOOKUP; for lookups with two conditions see How to look up a value with two criteria in Excel.
⬇Practice workbookExamples with live formulas + practice sheets · .xlsx · 14 KB

More how-to recipes