Nishaglobal Education logo

Looking up values: XLOOKUP and VLOOKUP

Pull information from another table automatically: find prices and categories with XLOOKUP, understand the older VLOOKUP you will meet at work, handle missing items, and look up bands such as commission rates.

Lesson 6 of 1240 minQuiz: 4 questions

🎯 By the end of this lesson you will be able to:

  • Look up a value in another table with XLOOKUP
  • Read and write VLOOKUP formulas, and know their limits
  • Handle missing matches and look up ranges such as rate bands
Outline
  1. What you'll learn and why it matters
  2. XLOOKUP
  3. When there is no match
  4. VLOOKUP: the one you will meet at work
  5. Looking up bands: approximate match
  6. Practice
  7. Common mistakes
  8. Recap
  9. Quiz
  10. Mark lesson complete

What you'll learn and why it matters

Information usually lives in more than one table: orders in one, product prices in another, staff details in a third. Lookups bring them together: for each order, find its product in the price list and fetch the price. It is the skill most often tested in Excel job interviews.

XLOOKUP

=XLOOKUP(lookup_value, lookup_array, return_array): find lookup_value in lookup_array, and return the matching item from return_array.

Worksheet: Sales

For each order, XLOOKUP finds the product in the Products table (E2:E7) and returns its price from G2:G7. The table ranges are locked with $ so the formula can be copied down.
RowABCDEFG
1ProductUnitsPriceProductCategoryPrice
2Sketchbook11300NotebookPaper120
3Pen set4250Pen setWriting250
4Sketchbook3300BackpackBags1500
5Notebook9120Water bottleAccessories400
6Notebook2120Desk lampAccessories1200
7Pen set8250SketchbookPaper300

Formulas (green cells)

  • C2 =XLOOKUP(A2,$E$2:$E$7,$G$2:$G$7) → 300
  • C3 =XLOOKUP(A3,$E$2:$E$7,$G$2:$G$7) → 250
  • C4 =XLOOKUP(A4,$E$2:$E$7,$G$2:$G$7) → 300
  • C5 =XLOOKUP(A5,$E$2:$E$7,$G$2:$G$7) → 120
  • C6 =XLOOKUP(A6,$E$2:$E$7,$G$2:$G$7) → 120
  • C7 =XLOOKUP(A7,$E$2:$E$7,$G$2:$G$7) → 250
For each order, XLOOKUP finds the product in the Products table (E2:E7) and returns its price from G2:G7. The table ranges are locked with $ so the formula can be copied down.
PartHereMeaning
lookup_valueA2What to look for: this order's product
lookup_array$E$2:$E$7Where to look: the product names
return_array$G$2:$G$7What to bring back: the prices

To fetch the category instead, just change the return array to $F$2:$F$7. In a real workbook the Products table is usually on its own sheet: then the range looks like Products!$A$2:$A$7.

When there is no match

If the value is not in the table, XLOOKUP returns #N/A. Give a fourth argument to show something friendlier:

Worksheet: Lookup

Stapler is not in the price list. With a fourth argument XLOOKUP shows Not found (B3); without it, #N/A (B4).
RowABCDE
1ProductPriceProductPrice
2Backpack1500Notebook120
3StaplerNot foundBackpack1500
4Stapler#N/ADesk lamp1200

Formulas (green cells)

  • B2 =XLOOKUP(A2,$D$2:$D$4,$E$2:$E$4,"Not found") → 1500
  • B3 =XLOOKUP(A3,$D$2:$D$4,$E$2:$E$4,"Not found") → Not found
  • B4 =XLOOKUP(A4,$D$2:$D$4,$E$2:$E$4) → #N/A
Stapler is not in the price list. With a fourth argument XLOOKUP shows Not found (B3); without it, #N/A (B4).

VLOOKUP: the one you will meet at work

Millions of existing spreadsheets use the older =VLOOKUP(lookup_value, table, column_number, FALSE). It looks in the first column of the table and returns the value from the column number you give:

Worksheet: Sales

The same prices with VLOOKUP: look for A2 in the first column of E2:G7 and return the 3rd column (Price). FALSE means exact match only.
RowABCDEFG
1ProductUnitsPrice (VLOOKUP)ProductCategoryPrice
2Sketchbook11300NotebookPaper120
3Pen set4250Pen setWriting250
4Sketchbook3300BackpackBags1500
5Notebook9120Water bottleAccessories400
6Notebook2120Desk lampAccessories1200
7Pen set8250SketchbookPaper300

Formulas (green cells)

  • C2 =VLOOKUP(A2,$E$2:$G$7,3,FALSE) → 300
  • C3 =VLOOKUP(A3,$E$2:$G$7,3,FALSE) → 250
  • C4 =VLOOKUP(A4,$E$2:$G$7,3,FALSE) → 300
  • C5 =VLOOKUP(A5,$E$2:$G$7,3,FALSE) → 120
  • C6 =VLOOKUP(A6,$E$2:$G$7,3,FALSE) → 120
  • C7 =VLOOKUP(A7,$E$2:$G$7,3,FALSE) → 250
The same prices with VLOOKUP: look for A2 in the first column of E2:G7 and return the 3rd column (Price). FALSE means exact match only.
XLOOKUPVLOOKUP
Look inAny columnOnly the first column of the table
ReturnAny column, left or rightA column number, to the right only
Exact matchBy defaultOnly if you write FALSE as the 4th argument
Inserting a column in the tableKeeps workingCan silently return the wrong column
Works in Excel 2016 and olderNoYes

Looking up bands: approximate match

For bands, such as *commission depends on the sales level*, list the lower edge of each band in ascending order. XLOOKUP with a 5th argument of -1 finds the exact value or the next smaller one:

Worksheet: Commission

Sales from 0 earn 2%, from 10,000 earn 4% and from 20,000 earn 6%. Asha's 14,250 is not in the table, so XLOOKUP uses the next smaller edge, 10,000: 4%.
RowABCDEF
1SalespersonSalesRateFromRate
2Asha142504%02%
3Ravi98702%100004%
4Meera214306%200006%

Formulas (green cells)

  • C2 =XLOOKUP(B2,$E$2:$E$4,$F$2:$F$4,,-1) → 4%
  • C3 =XLOOKUP(B3,$E$2:$E$4,$F$2:$F$4,,-1) → 2%
  • C4 =XLOOKUP(B4,$E$2:$E$4,$F$2:$F$4,,-1) → 6%
Sales from 0 earn 2%, from 10,000 earn 4% and from 20,000 earn 6%. Asha's 14,250 is not in the table, so XLOOKUP uses the next smaller edge, 10,000: 4%.

Practice

Guided exercise

Fetch the category

For each order, look up the product's category from the Products table.

  1. In C2 type =XLOOKUP(A2,$E$2:$E$7,$F$2:$F$7).
  2. Copy it down to C7.
Show the solution

Worksheet: Sales

RowABCDEFG
1ProductUnitsCategoryProductCategoryPrice
2Sketchbook11PaperNotebookPaper120
3Pen set4WritingPen setWriting250
4Sketchbook3PaperBackpackBags1500
5Notebook9PaperWater bottleAccessories400
6Notebook2PaperDesk lampAccessories1200
7Pen set8WritingSketchbookPaper300

Formulas (green cells)

  • C2 =XLOOKUP(A2,$E$2:$E$7,$F$2:$F$7) → Paper
  • C3 =XLOOKUP(A3,$E$2:$E$7,$F$2:$F$7) → Writing
  • C4 =XLOOKUP(A4,$E$2:$E$7,$F$2:$F$7) → Paper
  • C5 =XLOOKUP(A5,$E$2:$E$7,$F$2:$F$7) → Paper
  • C6 =XLOOKUP(A6,$E$2:$E$7,$F$2:$F$7) → Paper
  • C7 =XLOOKUP(A7,$E$2:$E$7,$F$2:$F$7) → Writing

How to get there: Only the return array changes, from the Price column (G) to the Category column (F). The $ signs keep the table in place as the formula is copied down.

Your turn

Line totals with a lookup

Work out each order's total in one formula: units times the price looked up from the table.

Show the solution

Worksheet: Sales

RowABCDEFG
1ProductUnitsTotalProductCategoryPrice
2Sketchbook113300NotebookPaper120
3Pen set41000Pen setWriting250
4Sketchbook3900BackpackBags1500
5Notebook91080Water bottleAccessories400
6Notebook2240Desk lampAccessories1200
7Pen set82000SketchbookPaper300

Formulas (green cells)

  • C2 =B2*XLOOKUP(A2,$E$2:$E$7,$G$2:$G$7) → 3300
  • C3 =B3*XLOOKUP(A3,$E$2:$E$7,$G$2:$G$7) → 1000
  • C4 =B4*XLOOKUP(A4,$E$2:$E$7,$G$2:$G$7) → 900
  • C5 =B5*XLOOKUP(A5,$E$2:$E$7,$G$2:$G$7) → 1080
  • C6 =B6*XLOOKUP(A6,$E$2:$E$7,$G$2:$G$7) → 240
  • C7 =B7*XLOOKUP(A7,$E$2:$E$7,$G$2:$G$7) → 2000

How to get there: A lookup can sit inside a bigger formula: XLOOKUP returns the price, which is multiplied by the units. 11 sketchbooks at 300 make 3,300.

Common mistakes

Not locking the lookup table with $

You see: #N/A further down the column as the range slides

Fix: Use $E$2:$E$7, or press F4 on the range.

VLOOKUP without FALSE

You see: Wrong values with no error

Fix: Always end VLOOKUP with , FALSE (or use XLOOKUP).

Extra spaces or different spelling

You see: #N/A for an item you can see

Fix: Clean the data with TRIM and check spelling.

Lookup and return arrays of different sizes

You see: #VALUE!

Fix: Both arrays must cover the same rows.

Recap

  • =XLOOKUP(value, lookup_array, return_array) finds a value and returns the matching item.
  • Add a 4th argument for a friendly result when nothing matches; lock table ranges with $.
  • VLOOKUP(value, table, column, FALSE) is older: first column only, and always use FALSE.
  • For bands, list lower edges in ascending order and use XLOOKUP's match mode -1.

Key terms

Lookup
Finding a value in one table and returning related information from it.
Exact match
A lookup that only succeeds when the value is found exactly.
#N/A
The error a lookup returns when no match is found.

Check your understanding

Answer all 4 questions, then check your answers to see an explanation for each one.

  1. 1. In =XLOOKUP(A2,E2:E7,G2:G7), what is G2:G7?

  2. 2. Why end VLOOKUP with FALSE?

  3. 3. A lookup returns #N/A for 'Backpack', which you can see in the table. What is the most likely cause?

  4. 4. What can XLOOKUP do that VLOOKUP cannot?

Answer all 4 questions to check.

Mark this lesson complete

Finished this lesson?

When you have worked through the examples and exercises, mark it complete to save your progress.