Contact Form

Name

Email *

Message *

VLOOKUP vs XLOOKUP in Google Sheets: Which One to Use

Dr/ sameh
VLOOKUP and XLOOKUP in Google Sheets
Photo: Pexels

Looking up a value from another table is one of the most useful things you can do in Google Sheets. Two functions do it: VLOOKUP, which has existed for years, and XLOOKUP, which is easier to read and more flexible. This guide shows both with the same small table so you can compare them and choose.

The sample table

Put this in a blank sheet, with headers in row 1: column A is ID, B is Name, C is Price.

A1: ID    B1: Name     C1: Price
A2: 101   B2: Mouse    C2: 20
A3: 102   B3: Keyboard C3: 35
A4: 103   B4: Monitor  C4: 180

In cell E1 type an ID, for example 102. We want the price for that ID in F1.

VLOOKUP

=VLOOKUP(E1, A2:C4, 3, FALSE)
  • E1 is the value to find.
  • A2:C4 is the table. VLOOKUP always searches the first column of this range.
  • 3 means: return the value from the third column of the range, which is Price.
  • FALSE means exact match. Leaving it out, or using TRUE, expects sorted data and can return a wrong result silently.

The result for 102 is 35.

XLOOKUP

=XLOOKUP(E1, A2:A4, C2:C4)
  • E1 is the value to find.
  • A2:A4 is the column to search.
  • C2:C4 is the column to return from.

You point at the two columns directly, so you do not count columns, and the search column does not have to be on the left. XLOOKUP matches exactly by default.

Handling missing values

If the ID is not in the table, both functions show #N/A. XLOOKUP lets you set a message as its fourth argument:

=XLOOKUP(E1, A2:A4, C2:C4, "Not found")

With VLOOKUP, wrap it in IFERROR:

=IFERROR(VLOOKUP(E1, A2:C4, 3, FALSE), "Not found")

Looking up to the left

To find the ID for a name, VLOOKUP cannot do it directly because the ID column is left of Name. XLOOKUP can:

=XLOOKUP("Monitor", B2:B4, A2:A4)

Which one should you use?

  • Use XLOOKUP in new sheets. It is easier to read and harder to break when you insert columns.
  • Use VLOOKUP when you are editing an older sheet that already uses it, or sharing with people who work in tools that do not support XLOOKUP.
  • Always use exact matching unless you really want an approximate match on sorted data.

Common mistakes

  • Extra spaces: "Mouse " does not match "Mouse". Use TRIM on the lookup value if data comes from copy and paste.
  • Numbers stored as text: 102 and "102" do not match. Make both the same type.
  • A range that does not lock when you copy the formula down. Use $A$2:$C$4 so it stays in place.

Sources

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.