Excel Lookup and Reference Functions: A Practical Guide

Learn Excel lookup and reference functions with XLOOKUP, VLOOKUP, INDEX, MATCH, XMATCH, FILTER, practical examples, and error fixes.

Excel lookup functions search for a key—such as a product ID or employee number—and return related information from the same record. Reference functions solve a different but connected problem: they return a position, value, or cell reference that another formula can use.

For most new workbooks, XLOOKUP is the clearest choice for a single match. FILTER is better when you need every matching record, while INDEX with XMATCH is useful for position-based and two-way lookups. VLOOKUP, HLOOKUP, and MATCH remain important when a workbook must work in older Excel versions.

The formulas in this guide use commas between arguments. Depending on your regional settings, Excel may use semicolons instead. Follow the separator shown by Formula AutoComplete.

Choose the lookup method by the result you need

Task Recommended method Why
Return one exact match in current Excel XLOOKUP Exact match is the default, and lookup and return ranges are separate
Return the position of a match XMATCH Returns a relative position and uses exact matching by default
Return every matching row FILTER Spills all qualifying records into neighboring cells
Build a two-way row-and-column lookup INDEX with two XMATCH functions Finds the intersection of a row label and column heading
Support Excel 2016 or 2019 INDEX/MATCH or VLOOKUP Avoids functions unavailable in those versions
Look across a horizontal legacy table HLOOKUP Searches the top row and returns from a specified row
Select one item from a fixed list CHOOSE Uses a position number rather than searching for a key
Return row or column information ROW, COLUMN, ROWS, COLUMNS Describes a reference for use in other formulas

Microsoft’s lookup and reference functions list includes the complete category. The sections below concentrate on the choices that matter most when building and troubleshooting everyday lookups.

Prepare the lookup data first

Assume cells A1:D7 contain this product table:

Product ID Product Region Unit Price
P-104Ceramic MugWest18.50
P-108Desk LampNorth42.00
P-112Canvas ToteEast16.00
P-116Water BottleWest24.00
P-120Notebook SetSouth12.50
P-124Phone StandNorth21.00

Before writing a formula, check four details:

  • The lookup key uses the same data type on both sides. A number and a number stored as text are not the same value.
  • Text keys do not contain accidental leading, trailing, or nonprinting characters.
  • The lookup and return ranges cover corresponding rows and have compatible dimensions.
  • The key is unique if the formula is supposed to return one authoritative record.

These checks prevent many formulas that are syntactically correct from returning #N/A or the wrong record.

Use XLOOKUP for a direct exact match

Enter a product ID such as P-116 in G2. The following formula searches A2:A7 and returns the corresponding price from D2:D7:

=XLOOKUP(G2,A2:A7,D2:D7,"Not found")

The returned value is 24; a two-decimal number format displays it as 24.00. The four arguments mean:

  1. Choose the lookup value. G2 contains the product ID to find.
  2. Choose the lookup array. A2:A7 contains the product IDs.
  3. Choose the return array. D2:D7 contains the prices to return.
  4. Define the no-match result. "Not found" appears instead of #N/A.

XLOOKUP uses exact matching when its optional match mode is omitted. It can return from a column on either side of the lookup column because the lookup and return arrays are independent. Microsoft documents the full syntax as:

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

The official XLOOKUP reference also explains wildcard, approximate, and reverse-search modes.

Return several columns with one formula

A wider return array can provide the product name, region, and price at once:

=XLOOKUP(G2,A2:A7,B2:D7,"Not found")

The three results spill across neighboring cells. Keep those cells empty; blocked output produces a #SPILL! error.

Choose which duplicate match to return

By default, XLOOKUP searches from the first item to the last and returns the first match. To search from the bottom upward and return the last match, set search_mode to -1:

=XLOOKUP(G2,A2:A7,D2:D7,"Not found",0,-1)

Choosing the first or last duplicate does not resolve inconsistent records. If a key should be unique, investigate the duplicates rather than silently accepting one.

Use VLOOKUP when compatibility matters

VLOOKUP searches the first column of a table array and returns a value from a numbered column in the same row. Using the product table, this exact-match formula returns the price for the ID in G2:

=VLOOKUP(G2,A2:D7,4,FALSE)

The number 4 tells Excel to return the fourth column of A2:D7. FALSE requests an exact match.

VLOOKUP has two structural limits: the lookup column must be the first column in the table array, and the return column is identified by a position number. If the layout changes, that hard-coded column number may need attention. XLOOKUP and INDEX/MATCH use separate lookup and return ranges, so they do not have the leftmost-column restriction.

In VLOOKUP, omitting the fourth argument defaults to approximate matching. Use FALSE explicitly for ordinary IDs, names, and codes. Microsoft’s VLOOKUP reference confirms the argument order and default.

HLOOKUP follows the same idea in a horizontal layout: it searches the top row and returns from a row number you specify. For a new workbook in a version that supports it, XLOOKUP can handle vertical or horizontal ranges without a separate function.

Combine INDEX with XMATCH or MATCH

XMATCH returns the relative position of a value rather than the related value itself. If G2 contains P-116, this returns 4 because that ID is fourth in A2:A7:

=XMATCH(G2,A2:A7)

INDEX can use that position to retrieve the fourth value from the price range:

=INDEX(D2:D7,XMATCH(G2,A2:A7))

The returned value is 24. XMATCH defaults to an exact match and can search from last to first. Its optional modes are described in Microsoft’s XMATCH reference.

For Excel 2016 or 2019, replace XMATCH with MATCH and specify 0 for an exact match:

=INDEX(D2:D7,MATCH(G2,A2:A7,0))

The zero matters. The default MATCH mode is approximate, whereas XMATCH defaults to exact matching. Microsoft’s MATCH documentation lists the sorting requirements for its approximate modes.

Build a two-way lookup with INDEX and XMATCH

A two-way lookup finds both a row and a column. Assume A10:D13 contains this quarterly sales table:

Product Q1 Q2 Q3
Ceramic Mug120135142
Desk Lamp807491
Canvas Tote150162171

If G10 contains Desk Lamp and G11 contains Q2, use:

=INDEX(B11:D13,XMATCH(G10,A11:A13),XMATCH(G11,B10:D10))

The first XMATCH returns row position 2. The second returns column position 2. INDEX returns the value at that intersection: 74. This mirrors the row-and-column form described in Microsoft’s INDEX reference.

Return every match with FILTER

A lookup normally returns one record. If G2 contains West and you need every product assigned to that region, use FILTER:

=FILTER(A2:D7,C2:C7=G2,"No matches")

The formula returns both the Ceramic Mug and Water Bottle rows and spills the results into adjacent cells. The third argument supplies a message when no rows qualify. The FILTER reference explains its Boolean include array and spill behavior.

Use XLOOKUP when one matching result is correct. Use FILTER when all matches are meaningful. That decision should come from the data model, not from whichever formula is shorter.

Use approximate matching only for defined bands

Approximate matching is appropriate for ordered thresholds such as commission bands, shipping tiers, or grading scales. Suppose J2:K6 contains minimum sales and discount rates:

Minimum Sales Discount
00%
10002%
25005%
50008%
1000010%

If G2 contains sales of 3200, this formula requests an exact match or the next smaller threshold:

=XLOOKUP(G2,J2:J6,K2:K6,"Below minimum",-1)

The result is 5%, the rate for the 2500 threshold. A compatible VLOOKUP formula is:

=VLOOKUP(G2,J2:K6,2,TRUE)

For approximate VLOOKUP, keep the first column in ascending order. An unsorted band table can produce a plausible but incorrect result. Exact matching should remain the default choice for identifiers and names.

Understand the reference side of the category

Not every function in the Lookup and Reference category searches a table. Some report information about a reference or select a value by position:

Formula Result Use
=ROW(C10) 10 Returns the row number of a reference
=COLUMN(C10) 3 Returns the column number of a reference
=ROWS(A2:A7) 6 Counts rows in a reference
=COLUMNS(A1:D1) 4 Counts columns in a reference
=CHOOSE(2,"Low","Medium","High") Medium Selects the second item from a fixed list
=ADDRESS(10,3) $C$10 Returns a cell address as text

INDIRECT can turn text such as "C10" into a reference, and OFFSET can return a reference shifted from a starting cell. These functions are useful when a genuinely dynamic reference is required, but a direct reference is usually easier to read and audit.

Handle lookup errors without hiding real problems

Symptom Likely cause What to check
#N/A No match, mismatched data types, or hidden spaces Compare the underlying values and clean the lookup key
Error from XLOOKUP Lookup and return arrays have incompatible dimensions Make sure corresponding ranges cover the same number of rows or columns
#REF! in VLOOKUP The requested column number falls outside the table array Count columns from the first column of the selected table array
#SPILL! Cells block a multi-column XLOOKUP or FILTER result Clear the indicated spill range and check for merged cells
Wrong value without an error Approximate mode was used unintentionally or duplicates exist Use exact mode and check key uniqueness
#NAME? The Excel version does not support the function or its name is misspelled Confirm version compatibility and formula spelling

XLOOKUP has a built-in if_not_found argument. For a legacy formula, IFNA can replace only the expected #N/A result:

=IFNA(INDEX(D2:D7,MATCH(G2,A2:A7,0)),"Not found")

This is narrower than wrapping the formula in IFERROR, which can conceal unrelated problems such as an invalid reference. Microsoft’s IFNA reference confirms that it handles the #N/A error specifically.

Check version compatibility before sharing

Functions Current availability Compatibility choice
XLOOKUP, XMATCH Microsoft 365, Excel 2021, and Excel 2024 Use INDEX/MATCH or VLOOKUP for Excel 2016 and 2019
FILTER Microsoft 365, Excel 2021, and Excel 2024 Older versions need another formula strategy, Advanced Filter, or Power Query
VLOOKUP, HLOOKUP, INDEX, MATCH Excel 2016, 2019, 2021, 2024, and Microsoft 365 Use when recipients do not have the newer functions

Microsoft states that XLOOKUP is not available in Excel 2016 or Excel 2019. A workbook created in a newer version may therefore show an unsupported-function result when opened in those releases.

Frequently asked questions

Why does a lookup return #N/A when the values look identical?

One value may be numeric while the other is text, or one may contain hidden spaces or nonprinting characters. Compare the underlying types and clean the keys before changing the lookup formula.

Can XLOOKUP return a value from the left?

Yes. The lookup array and return array are separate, so the return range may be to the left or right of the lookup range. VLOOKUP, by contrast, requires the lookup column to be first in its table array.

Does XLOOKUP return all duplicates?

No. It returns the first match by default, or the last match when you use reverse search mode. Use FILTER when you need every matching row.

When should I use approximate matching?

Use it for deliberately defined bands such as tax thresholds, commission rates, or score ranges. Use exact matching for product codes, employee IDs, account numbers, and other keys that should match one specific record.

Make the lookup rule explicit

A reliable lookup states three things clearly: the key to find, the field to return, and the rule for unmatched or duplicate data. XLOOKUP expresses those choices directly in current Excel. INDEX with XMATCH handles position-based and two-way work, while FILTER covers one-to-many results. Legacy functions remain valuable when compatibility is part of the requirement.

Whichever method you choose, test missing keys, duplicates, mixed data types, and approximate-match boundaries. The formula is only as dependable as the lookup rule and the source data behind it.