Useful Data Tips

VLOOKUP vs XLOOKUP

📊 Excel ⏱️ 30 sec read

Quick Summary

VLOOKUP: Legacy lookup function, searches left-to-right only

XLOOKUP: Modern replacement, more powerful and flexible

Verdict: Use XLOOKUP if you have Excel 365. Stick with VLOOKUP for older versions.

VLOOKUP Syntax

=VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup])

Example:
=VLOOKUP(A2, Products!A:D, 3, FALSE)

Parameters:
- A2: Value to look up
- Products!A:D: Table to search in
- 3: Return value from 3rd column
- FALSE: Exact match

XLOOKUP Syntax

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

Example:
=XLOOKUP(A2, Products!A:A, Products!D:D)

Parameters:
- A2: Value to look up
- Products!A:A: Column to search in
- Products!D:D: Column to return from
(Much simpler!)

Key Differences

Feature VLOOKUP XLOOKUP
Direction Left-to-right only Any direction
Column reference By number (breaks if inserted) By range (doesn't break)
Lookup left ❌ Cannot ✅ Can
Default match Approximate (confusing!) Exact
Not found #N/A error Custom message
Multiple returns ❌ No ✅ Yes

Example: Basic Lookup

Sample Data

Products Table:
| Product ID | Name      | Category  | Price |
|-----------|-----------|-----------|-------|
| P001      | Laptop    | Electronics| $999 |
| P002      | Mouse     | Electronics| $29  |
| P003      | Desk      | Furniture | $299 |

VLOOKUP

Task: Look up price for P002

=VLOOKUP("P002", A2:D4, 4, FALSE)

Result: $29

Problems:
1. Must count columns (4th column)
2. Can't lookup Name if Price comes first
3. Insert column? Formula breaks!

XLOOKUP

Task: Look up price for P002

=XLOOKUP("P002", A2:A4, D2:D4)

Result: $29

Benefits:
1. Direct column reference
2. Can lookup in any direction
3. Insert columns? Still works!

XLOOKUP Advantages

1. Lookup to the Left

Task: Find Product ID from Price

VLOOKUP: ❌ Can't do this (ID is left of Price)

XLOOKUP: ✅ Easy!
=XLOOKUP(999, D2:D4, A2:A4)
Returns: P001

2. Custom Error Message

VLOOKUP:
=IFERROR(VLOOKUP(A2, Products!A:D, 4, FALSE), "Not Found")

XLOOKUP:
=XLOOKUP(A2, Products!A:A, Products!D:D, "Not Found")
(Built-in!)

3. Multiple Column Return

XLOOKUP can return multiple columns:
=XLOOKUP(A2, Products!A:A, Products!B:D)

Returns all columns B through D at once!

4. Search Modes

XLOOKUP search modes:
- 1: Exact match (default)
- -1: Exact match or next smaller
- 1: Exact match or next larger
- 2: Wildcard match

Example (wildcard):
=XLOOKUP("Lap*", Products!B:B, Products!D:D, , 2)
Finds "Laptop" even with partial text

When VLOOKUP is Still OK

Common VLOOKUP Mistakes

Mistake 1: Forgetting FALSE

WRONG:
=VLOOKUP(A2, Products!A:D, 3)
(Defaults to approximate match - usually wrong!)

RIGHT:
=VLOOKUP(A2, Products!A:D, 3, FALSE)

Mistake 2: Hard-Coded Column Number

WRONG:
=VLOOKUP(A2, Products!A:D, 3, FALSE)
(If someone inserts column, returns wrong data!)

BETTER:
=VLOOKUP(A2, Products!A:D, MATCH("Price", Products!1:1, 0), FALSE)
(Uses MATCH to find column dynamically)

Mistake 3: Including Lookup Column in Range

INEFFICIENT:
=VLOOKUP(A2, Products!A:Z, 4, FALSE)
(Searches entire sheet)

BETTER:
=VLOOKUP(A2, Products!A:D, 4, FALSE)
(Only includes needed columns)

Migrating VLOOKUP to XLOOKUP

Before (VLOOKUP)

=IFERROR(VLOOKUP($A2, Products!$A:$D, 3, FALSE), "Not Found")

After (XLOOKUP)

=XLOOKUP($A2, Products!$A:$A, Products!$C:$C, "Not Found")

XLOOKUP Advanced Features

Horizontal Lookup (No HLOOKUP Needed)

Data is in rows instead of columns?
=XLOOKUP(A2, Products!1:1, Products!4:4)

XLOOKUP works both directions!

Two-Way Lookup

Lookup both row AND column:
=XLOOKUP(row_value, row_array, XLOOKUP(col_value, col_array, data_array))

Find Last Occurrence

=XLOOKUP(A2, Products!A:A, Products!D:D, , 0, -1)

Last parameter -1: Search from bottom up

Performance Comparison

Both functions have similar speed for typical use cases. XLOOKUP may be slightly faster with large datasets because it doesn't need to load the entire table.

Compatibility

INDEX/MATCH Alternative

Works in all Excel versions, more flexible than VLOOKUP:

=INDEX(return_column, MATCH(lookup_value, lookup_column, 0))

Example:
=INDEX(Products!D:D, MATCH(A2, Products!A:A, 0))

Advantages over VLOOKUP:
✅ Can lookup left
✅ Doesn't break when columns inserted
✅ Works in older Excel

But XLOOKUP is simpler!

Quick Reference

VLOOKUP:
=VLOOKUP(lookup, table, col, FALSE)

XLOOKUP:
=XLOOKUP(lookup, lookup_col, return_col, "Not Found")

INDEX/MATCH:
=INDEX(return_col, MATCH(lookup, lookup_col, 0))

Best Practices

Key Takeaways:

  • XLOOKUP is the future: Use it if you have Excel 365
  • VLOOKUP still works: Fine for simple cases
  • XLOOKUP can lookup left, VLOOKUP cannot
  • XLOOKUP has better error handling
  • XLOOKUP doesn't break when columns inserted
  • For older Excel, use INDEX/MATCH instead of VLOOKUP