Skip to content
Administrative Support

Spreadsheet Lookup Functions

15 min read Training Guide

Pull matching details from another list with XLOOKUP, VLOOKUP or INDEX and MATCH, choose exact or tiered matching, and fix the usual reasons a lookup fails.

Table of contents

A lookup finds a value in one list and brings back a matching detail from the same row. Type a part number and get its price. Type an employee ID and get a department. Type a package weight and get the shipping rate. Lookups save hours of copying, but a lookup that is set up wrong returns a believable wrong answer, which is worse than an error. This guide covers the three common ways to do it in Excel and Google Sheets and the problems that break them.

What You Will Be Able to Do

  • Write an XLOOKUP, a VLOOKUP and an INDEX and MATCH that return the same answer.
  • Choose an exact match for IDs and an approximate match for tiered rates.
  • Know which lookup works in which program and version.
  • Find the cause when a lookup returns #N/A or the wrong row.
  • Spot-check lookup results before you send them on.

How a Lookup Works

Every lookup needs three things:

  1. The lookup value. What you have, such as part number P-310.
  2. The column to search. Where that value appears in the other list, such as the Part No column.
  3. The column to return. What you want back, such as Price.

The column you search is the key. It works best when each value appears only once, like an ID, an SKU or an email address. Names make poor keys because two people can share one.

Which Lookup to Use

Function Where it works Good to know
XLOOKUP Excel for Microsoft 365, Excel 2021 and later, Excel for the web, Google Sheets Exact match unless you say otherwise. Can look left.
VLOOKUP Every version of both programs Approximate match unless you say FALSE. Searches only the first column.
INDEX and MATCH Every version of both programs Two functions together. Can look left.

XLOOKUP is the easiest to get right. If people open your file in Excel 2019 or earlier, your XLOOKUP results turn into #NAME? as soon as the sheet recalculates. Use VLOOKUP or INDEX and MATCH in a file that has to work for them.

Worked Example: A Price List

The price list sits on a sheet named Prices:

A B C
1 Part No Description Price
2 P-100 Hinge 4.25
3 P-205 Door stop 3.10
4 P-310 Latch 12.80
5 P-415 Strike plate 2.95

On an order sheet, A2 holds P-310. Each of these formulas in B2 returns 12.80.

XLOOKUP

=XLOOKUP(A2,Prices!$A$2:$A$5,Prices!$C$2:$C$5,"Not found")

The arguments are, in order: what to find, where to look, what to return, and what to show if there is no match. Excel names them lookup_value, lookup_array, return_array and if_not_found. Google Sheets calls them search_key, lookup_range, result_range and missing_value, but they work the same. Leave out the fourth one and a miss shows #N/A.

Change C2:C5 to B2:B5 and the same formula returns Latch. The search column and return column can be anywhere, even with the return column to the left.

VLOOKUP

=VLOOKUP(A2,Prices!$A$2:$C$5,3,FALSE)

The arguments are: what to find, the whole table, which column of the table to return, and FALSE for an exact match. VLOOKUP always searches the first column of the table you give it, and the column number counts from there. Part No is 1, Description is 2 and Price is 3.

Warning: Always type FALSE as the last argument when you look up IDs, part numbers or names. If you leave it out, both Excel and Google Sheets use approximate matching. On an unsorted list, that can return a price from the wrong row with no error at all.

INDEX and MATCH

=INDEX(Prices!$C$2:$C$5,MATCH(A2,Prices!$A$2:$A$5,0))

MATCH finds the position of P-310 in the Part No column. It is the 3rd item, so MATCH returns 3, and the 0 asks for an exact match. INDEX then returns the 3rd item in the Price column, 12.80. Like XLOOKUP, it can return a column to the left of the search column.

Lock the Table Before You Copy

The dollar signs in Prices!$A$2:$A$5 keep the table in place when you copy the formula down the order sheet. Without them, the next row looks in A3:A6, then A4:A7, and the top of the price list drops out one row at a time. Lookups near the bottom start failing while the ones at the top still work.

A sheet name with a space needs single quotes: 'Price List'!$A$2:$A$5. Clicking the other sheet's tab while you write the formula adds the name for you.

Approximate Match for Tiers

Some lookups are not meant to find an exact value. A shipping rate depends on which weight band a package falls in. A tier table lists the lowest weight of each band, smallest first.

A B
1 Min Weight (lb) Rate
2 0 8.00
3 5 12.50
4 20 25.00
5 50 60.00

A 12-pound package belongs in the 5-pound band, so the rate is 12.50. With the weight in D2:

  • XLOOKUP: =XLOOKUP(D2,$A$2:$A$5,$B$2:$B$5,"Check",-1). The -1 means "exact match, or the next smaller value".
  • VLOOKUP: =VLOOKUP(D2,$A$2:$B$5,2,TRUE). TRUE means approximate.
Weight Band used Rate returned
4.9 0 8.00
5 5 12.50
12 5 12.50
50 50 60.00
75 50 60.00

Rules for tier tables:

  • Sort the bands smallest to largest. VLOOKUP with TRUE requires it and returns wrong answers without it. XLOOKUP's -1 still works unsorted, but a sorted table is easier for people to check.
  • Start the first band at the lowest possible value, here 0. A weight below the first band has no match.
  • Write down the edge rule. Here, exactly 5 pounds gets the 5-pound rate. Make sure that matches the real rate sheet.

Why a Lookup Fails

What you see Likely cause How to check and fix
#N/A, but you can see the value An extra space, such as "P-310 " =LEN(A2) shows 6, not 5. Clean it with TRIM.
#N/A on numbers One list has numbers stored as text =ISNUMBER(A2) returns FALSE on one side. Convert the text to numbers.
A wrong value, with no error VLOOKUP without FALSE on an unsorted list Add FALSE as the last argument
Rows near the bottom fail or go wrong The table range was not locked Add dollar signs and copy again
Values shifted after someone edited the list A column was inserted, and VLOOKUP's column number did not change Fix the number, or switch to XLOOKUP
#REF! from VLOOKUP The column number is larger than the table is wide Count the columns again
#NAME? XLOOKUP in Excel 2019 or earlier, or a misspelled function Use VLOOKUP, or check the spelling
The answer is from the wrong person The key has duplicates, and the lookup returns the first match Use a unique key, such as an ID

Lookups ignore capital letters, so p-310 finds P-310. They do not ignore spelling, spaces or punctuation. "Doorstop", "Door stop" and "Door-stop" are three different values.

Find hidden spaces. =LEN(A2) counts every character, including spaces you cannot see. "P-310" has 5 characters. If LEN says 6, there is a space. You can wrap the lookup value in TRIM, as in =XLOOKUP(TRIM(A2),...), but cleaning the source list fixes the problem once for everyone.

Find numbers stored as text. An employee ID typed as 1042 in one list and stored as the text "1042" in the other will never match. In both programs, text sits on the left of the cell by default and numbers on the right, which is a quick visual check.

Handling Values That Are Not Found

Some misses are expected, such as a new part not yet on the price list. Showing "Not found" is clearer than #N/A.

  • With XLOOKUP, use the fourth argument: "Not found".
  • With VLOOKUP or INDEX and MATCH, wrap the formula: =IFERROR(VLOOKUP(A2,Prices!$A$2:$C$5,3,FALSE),"Not found").

IFERROR hides every error, not just misses. A wrong range or a broken reference also turns into "Not found". Build the lookup without IFERROR first, check that it works, and add IFERROR last.

Count the misses so they do not slip past you: =COUNTIF(B2:B200,"Not found"). Then look at each one. A miss usually means a typo, a missing record or a cleanup problem, and each one is worth knowing about.

Spot-Check Before You Send It

  1. Pick three rows, one near the top, one in the middle and one at the bottom.
  2. Find each one by hand. Press Ctrl+F in the source list, search for the key, and compare the value you see with what the lookup returned.
  3. Check the bottom row closely. An unlocked range fails at the bottom first.
  4. Count the misses with COUNTIF, and explain each one.
  5. For tiers, test the edges. Try a value exactly on a band limit and one just under it, such as 5 and 4.9.

Common Mistakes

Mistake What it costs
Leaving off FALSE in VLOOKUP Wrong prices or names with no error to warn you
Not locking the table range Lookups fail one by one down the sheet
Using names as the key The wrong person's details
Hard-coding VLOOKUP's column number, then inserting a column Every result shifts to the wrong column
Wrapping everything in IFERROR from the start Setup mistakes hide behind "Not found"
Using XLOOKUP in a file shared with older Excel Coworkers see #NAME? everywhere

Check Your Understanding

1. Your VLOOKUP finds most customer IDs, but a few return #N/A even though you can see those IDs in the customer list. What do you check first?

Check for extra spaces with LEN, and check whether one list stores the IDs as text with ISNUMBER. Those two causes explain most lookups that fail on a value you can see.

2. A coworker's VLOOKUP returns a price for every part, but some prices are wrong. The formula is =VLOOKUP(A2,Prices!A2:C200,3). What two problems do you see?

There is no FALSE, so it uses approximate matching on what is probably an unsorted list. And the table range has no dollar signs, so it slides down as the formula is copied. Use =VLOOKUP(A2,Prices!$A$2:$C$200,3,FALSE).

3. A commission table lists sales tiers starting at 0, 10,000 and 25,000. A rep sold 25,000 exactly. Which tier does =XLOOKUP(B2,A2:A4,C2:C4,"Check",-1) use?

The 25,000 tier, because -1 looks for an exact match first and 25,000 is in the table. Confirm that the company's plan also puts 25,000 in that tier.

4. Your workbook uses XLOOKUP, and a client says every result shows #NAME?. What is likely going on?

The client is probably on Excel 2019 or earlier, which does not have XLOOKUP. Rewrite those formulas with VLOOKUP or INDEX and MATCH, or send the values instead of the formulas.

Key Takeaways

  • A lookup needs a value, a column to search and a column to return, and it works best with a unique key.
  • XLOOKUP is exact by default and can look left. VLOOKUP needs FALSE for an exact match.
  • Lock the table range with dollar signs before you copy a lookup down.
  • Tier tables use approximate match, start at the lowest value and are sorted smallest first.
  • Most failures come from extra spaces, numbers stored as text, an unlocked range or a missing FALSE.
  • Add IFERROR last, count the misses, and spot-check rows at the top, middle and bottom.