FORMULAS & FUNCTIONS

How to Use XLOOKUP for an Exact Match in Excel

XLOOKUP can return a value from another column without counting column positions or rewriting the formula when the table changes. This guide shows how to build an exact-match lookup, return a clear message when nothing is found, and verify that the result comes from the correct source row.

Excel XLOOKUP exact-match hero showing product ID P-104 matched to Monitor with the XLOOKUP formula and highlighted source row
← Tutorial HubFormulas & Functions

Best use: use XLOOKUP when you have a unique code, name, invoice number, product ID, or other key and need to return related information from the same record.

Why exact matching matters

A lookup formula should return the record that matches the selected key—not merely the nearest value in a sorted list. Exact matching is especially important for employee IDs, account codes, invoice numbers, stock keeping units, and other identifiers where a similar value belongs to a different record.

XLOOKUP uses exact matching by default. Adding an explicit match mode of 0 can still make the intended behavior easier for another workbook user to audit, especially when the formula is copied into a shared report.

Understand the XLOOKUP structure

The function accepts a value to find, the single row or column to search, the row or column to return, and optional controls for missing values, match mode, and search mode:

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
ArgumentPurpose
lookup_valueThe code, name, or value you want to find.
lookup_arrayThe single row or column containing possible matches.
return_arrayThe row or column containing the result to return.
if_not_foundAn optional message or value when no match exists.
match_modeUse 0 for an explicit exact match.
search_modeControls search direction and optional binary-search behavior.

1. Prepare a clean lookup table

Start with one row per record and a lookup column that contains the key. In an employee list, column A might contain Employee ID, column B the employee name, column C the department, and column D the hourly rate. Keep the lookup key consistent and, when the business rule requires it, unique.

  • Keep lookup values in one continuous row or column.
  • Use the same data type for the lookup cell and source values.
  • Remove accidental spaces or hidden characters from imported text.
  • Confirm that duplicate keys are intentional before relying on the result.
  • Convert the source range to an Excel Table when it will grow over time.

If imported identifiers need cleanup before the lookup, use the split-text workflow to separate or inspect the source values before building the formula.

Excel employee lookup source table highlighting a clean Employee ID key column before using XLOOKUP

2. Build the exact-match formula

Assume the employee ID to find is entered in H2. The source IDs are in A2:A8, and the department to return is in C2:C8. A clear exact-match formula is:

=XLOOKUP(H2,$A$2:$A$8,$C$2:$C$8,"Not found",0)

Excel searches A2:A8 for the value in H2. When it finds an exact match, it returns the value from the same row in C2:C8. If the ID is missing, the formula returns “Not found” instead of displaying #N/A. The dollar signs keep the source ranges fixed if the formula is copied.

Audit tip: after the formula returns a result, locate the source row manually and confirm that both the key and returned value come from the same record.

3. Handle missing values without hiding real problems

The if_not_found argument is useful for user-facing forms and reports. Choose a message that tells the user what happened. “Not found” is usually clearer than a blank because it distinguishes a missing record from a formula that has not been completed.

Do not use the message to avoid investigating why a key is missing. Check for typing mistakes, extra spaces, leading zeros, text-versus-number differences, and outdated source data. A clean message improves the worksheet, but the source issue still needs review. If a text-versus-number mismatch is the cause, compare the values with the data-type checking guide.

Excel exact-match XLOOKUP showing a lookup value, matching employee source row, formula, and returned department

4. Return more than one column

In current Microsoft 365 versions, XLOOKUP can return several adjacent columns at once. To return the employee name, department, and rate from columns B:D, use:

=XLOOKUP(H2,$A$2:$A$8,$B$2:$D$8,"Not found",0)

The results spill into neighboring cells. Keep the destination area empty, or Excel will return a #SPILL! error. Use this approach when the fields belong together and the worksheet has enough space. For a single report column, returning only the needed field is usually easier to maintain.

Excel XLOOKUP verification checklist showing matching, missing-value, duplicate-key, and source-row checks

5. Use structured references in an Excel Table

If the source is an Excel Table named tblEmployees, the formula can use field names instead of fixed coordinates:

=XLOOKUP(H2,tblEmployees[Employee ID],tblEmployees[Department],"Not found",0)

Structured references are easier to read and expand automatically when new rows are added. Confirm the table name and column headings exactly. A renamed heading updates formulas inside the same table, but a copied formula from another workbook may refer to a table that does not exist.

6. Test matching and nonmatching cases

  1. Enter a key that you know exists and compare the result with the source row.
  2. Enter a key that does not exist and confirm the “Not found” message.
  3. Test a value with a leading zero if the source uses text identifiers.
  4. Copy the formula where required and confirm that the lookup cell changes while the source arrays stay fixed.
  5. Add a new source row when using a Table and confirm the lookup includes it.

Common XLOOKUP problems

ProblemWhat to check
Valid key returns “Not found”Compare data types, spaces, hidden characters, and leading zeros.
Wrong record is returnedLook for duplicate keys and confirm the lookup array is the correct column.
#VALUE! appearsConfirm the lookup and return arrays have compatible dimensions.
#SPILL! appearsClear the cells needed for a multi-column result.
Formula breaks when copiedLock fixed source ranges or use an Excel Table.
XLOOKUP is unavailableThe Excel version may not support the function; use INDEX and MATCH or another compatible method.

Duplicate-key warning: standard XLOOKUP returns the first matching record. If the key should be unique, investigate duplicates instead of assuming the first result is correct.

Final XLOOKUP verification checklist

  • The lookup cell and source key use compatible data types.
  • The lookup array contains the intended key field.
  • The return array aligns with the same source rows.
  • The exact-match behavior is clear.
  • The missing-value message is useful and not misleading.
  • Known matching and nonmatching examples were tested.
  • Duplicate keys, leading zeros, and imported text were reviewed.
  • The result agrees with the source record.

Frequently asked questions

Does XLOOKUP use exact matching automatically?

Yes. Exact matching is the default. Adding 0 as the match mode is optional, but it can make the intended behavior more obvious to someone reviewing the formula.

Can XLOOKUP search to the left?

Yes. The return array can be to the left or right of the lookup array because XLOOKUP does not depend on a column index number.

What happens when the lookup value is duplicated?

The normal search returns the first match. You can change the search mode to search from the last item, but duplicate business keys should usually be reviewed and corrected.

Does XLOOKUP work in every Excel version?

No. It is available in supported modern Excel versions, including Microsoft 365, but older perpetual versions may not include it. Use a compatible INDEX-and-MATCH formula when the workbook must support those versions.

Build more dependable Excel lookups

Continue with the OneXcel Tutorial Hub or explore free Excel resources.