1XLOOKUP
=XLOOKUP(F2,B2:B9,A2:A9)
- Type =XLOOKUP( then the value to find, F2.
- Select the column to search, B2:B9, then the column to return, A2:A9.
- Add a fourth argument such as "Not found" for names that are not in the list.
Find a value in one column and return a value from a column to its left, using XLOOKUP or INDEX and MATCH, which VLOOKUP cannot do.
A staff list has the employee ID in column A and the name in column B. You have a name and need the ID. The ID is to the left of the name, and VLOOKUP cannot reach it.
VLOOKUP always searches the first column of its table and can only return from columns to the right. To look left you have two options, and neither needs the columns rearranged.
XLOOKUP takes the column to search and the column to return as separate arguments, so their order on the sheet does not matter:
=XLOOKUP(F2, B2:B9, A2:A9)
Search the Name column, return the ID column. That is the whole formula. It matches exactly by default, and its fourth argument controls what shows when nothing matches.
INDEX and MATCH have worked in every version for decades:
=INDEX(A2:A9, MATCH(F2, B2:B9, 0))
MATCH finds the position of the name in column B. INDEX returns the item at that position from column A. The 0 makes MATCH look for an exact match, and leaving it out is a classic source of wrong answers.
Both return the first match when a name appears twice. If names are not unique, look up on something that is, such as an ID, or add a second criterion.
You could also swap the columns, but that breaks other formulas that point at them. The Lookups track covers XLOOKUP, INDEX and MATCH, and when each one is the better choice.
=XLOOKUP(F2,B2:B9,A2:A9)
=INDEX(A2:A9,MATCH(F2,B2:B9,0))
Solve it in the sheet. Every answer is checked, with hints if you need them.
Task 1 of 2
In G2, return the employee ID for the name in F2. The ID column is to the left of the names.
Answer in G2.
Logic and text covers this in lesson 14, TEXTSPLIT.