The firm opens soon. Guides and calculators are already free to use —get notified when we open
Excel

Excel: XLOOKUP, INDEX-MATCH and VLOOKUP to retrieve data (chart of accounts, customers, pricing)

Look up an account name, VAT rate or customer with XLOOKUP, INDEX-MATCH or VLOOKUP: syntax, approximate match and fixing #N/A errors.

Published 9 min readLevel: IntermediateEl Arabi Aich

In brief
  • XLOOKUP searches for a value in one column and returns the corresponding value from another column: =XLOOKUP(lookup_value, lookup_array, return_array, if_not_found).
  • It improves on VLOOKUP: no column index number to count, searches in either direction, and includes a built-in default value.
  • For Excel versions earlier than 2021, the INDEX + MATCH combination offers the same flexibility.
  • Approximate matching classifies an amount into a bracket (tax scale, receivables ageing, rate tier).

Looking up information in a table using a key is the most frequent task an accountant performs in Excel: finding an account title from its number, a product’s VAT rate, a customer’s company name from its Common Company Identifier (ICE), or the tax band to apply to an amount. Three methods exist. Here is how to choose and use them.

The scenario: adding labels to a trial balance

A raw trial balance only displays account numbers. We want to add the account title, pulled from the chart of accounts in columns F and G.

XLOOKUP, the modern method

Syntax:

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

In cell B2 of the trial balance:

=XLOOKUP(A2,$F$2:$F$6,$G$2:$G$6,"Unknown account")

Trial balance on the left and chart of accounts on the right: the Title column in the trial balance is populated by XLOOKUP, displaying Unknown account for account 6199 Figure 1: marker 1 shows the formula, marker 2 the chart of accounts (keys in F, titles in G), and marker 3 an account missing from the chart. (Note: the screenshot shows the French-language Excel interface using RECHERCHEX and ; separators, while the formulas in the text use English Excel syntax.)

How to read it: “look up the value of A2 in F2:F6 and return the value on the same row in G2:G6; if it does not exist, write Unknown account”. Copy the formula down. Thanks to the $ signs, the ranges stay locked.

Advantages:

  • no need to count column numbers;
  • the lookup column can sit to the right of the result column;
  • the “if not found” value prevents #N/A errors;
  • the search mode lets you search from the bottom up (last occurrence).

VLOOKUP, the legacy method

=VLOOKUP(A2,$F$2:$G$6,2,FALSE)

The four arguments: lookup value, table range (the key must be in the first column), column index number to return (here 2), and FALSE for an exact match. Limitations: the key must be on the left; the column number breaks if you insert a column; forgetting FALSE causes silent wrong results.

INDEX + MATCH, the universal method

Works in all versions of Excel:

=IFERROR(INDEX($G$2:$G$6,MATCH(A2,$F$2:$F$6,0)),"Unknown account")
  • MATCH(A2,$F$2:$F$6,0) returns the position of A2 in the key column (0 = exact match).
  • INDEX($G$2:$G$6,position) returns the value from the result column at that position.
  • IFERROR replaces any error with custom text.

Which tool should you choose?

Criterion XLOOKUP INDEX + MATCH VLOOKUP
Excel version 2021 / 365 All All
Key to the right of result Yes Yes No
Resilient to inserted columns Yes Yes No
Built-in default value Yes Via IFERROR Via IFERROR
Readability Very good Moderate Good

Recommendation: use XLOOKUP whenever available; otherwise use INDEX-MATCH. Avoid VLOOKUP in any new workbook.

Approximate match: finding the right bracket

Another use case is classifying an amount into a bracket. For an aged receivables report, consider an overdue-days table:

Days (start) Bracket
0 Not due
1 1–30 d
31 31–60 d
61 61–90 d
91 > 90 d

For an invoice 75 days overdue in D2:

=XLOOKUP(D2,$H$2:$H$6,$I$2:$I$6,"",-1)

Match mode -1 returns the exact match or next smaller item (here 61 → “61–90 d”). With INDEX-MATCH: =INDEX($I$2:$I$6,MATCH(D2,$H$2:$H$6,1)) (the key column must be sorted in ascending order).

The same principle applies to a personal income tax (IR) scale (see calculating IR), a commission grid or depreciation rate tables.

Looking up across multiple columns at once

To retrieve VAT by product and rate or a balance by account and period, create a composite key: in the data column =A2&"|"&B2, then look up =XLOOKUP(F2&"|"&G2,Keys,Values). For a numeric result, SUMIFS is simpler (see the tutorial).

Avoiding common traps

  1. Mismatched formats: account 5141 stored as a number in the trial balance and as text in the chart of accounts produces #N/A. Standardise with =TEXT(A2,"0").
  2. Hidden spaces: apply TRIM() to imported columns.
  3. Duplicates in the reference table: every lookup key should be unique.
  4. Unlocked ranges: forgetting $ causes the lookup range to shift when copied.
  5. Sorting required for approximate matches with MATCH (match type 1).
  6. Rows added to the reference table: convert it to an Excel Table (Ctrl+T) so ranges expand automatically.

XLOOKUP options worth knowing

The full syntax is:

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

Optional argument Values Effect
if_not_found text or value Replaces #N/A (for example "Unknown account")
match_mode 0 (default) Exact match
-1 Exact match, or next smaller item
1 Exact match, or next larger item
2 Wildcard characters (*, ?)
search_mode 1 (default) First to last
-1 Last to first (finds the latest occurrence)

Accounting examples

Requirement Formula
Account title, with message if missing =XLOOKUP(A2,Chart[Account],Chart[Title],"Unknown account")
Date of a customer’s latest invoice =XLOOKUP(A2,Sales[Customer],Sales[Date],"",0,-1)
Discount tier by volume (next smaller threshold) =XLOOKUP(B2,Scale[Threshold],Scale[Rate],0,-1)
Account whose title contains “bank” =XLOOKUP("*bank*",Chart[Title],Chart[Account],"",2)
Multiple columns at once (dynamic array) =XLOOKUP(A2,Chart[Account],Chart[[Title]:[Class]])

The last formula returns several cells from a single formula entry (the results “spill” to the right): no need to write a separate formula per column.

Practical case: following up each customer’s latest invoice

A sales table sorted by date contains three invoices for customer “Atlas”: 10/01, 14/02 and 03/03. The formula =XLOOKUP("Atlas",Sales[Customer],Sales[Date],"",0,-1) returns 03/03 (the most recent), whereas the default mode would return 10/01. Combined with =TODAY()-date, it gives the age of the latest invoice and helps identify inactive customers.

When to stick with INDEX + MATCH

XLOOKUP only exists in Excel 2021, Excel for Microsoft 365 and recent web versions. For a workbook shared with users on older versions, INDEX + MATCH remains the compatible choice:

=INDEX(Chart[Title],MATCH(A2,Chart[Account],0))

Choose based on your recipients’ Excel version, and document the formula in a note cell inside the workbook.

Practical case: calculating income tax (IR) with a bracket table

The income tax (IR) scale is well suited to an approximate lookup. Create a table listing, for each bracket, the lower threshold, the rate and the fixed deduction (see IR calculation).

Lower threshold (income above) Rate Amount to deduct
0 0% 0
40,000.01 10% 4,000
60,000.01 20% 10,000
80,000.01 30% 18,000
100,000.01 34% 22,000
180,000.01 37% 27,400

If annual net taxable income is in cell B2 and the table is named “Scale” (columns Threshold, Rate, Deduction), the tax formula is:

=B2*XLOOKUP(B2,Scale[Threshold],Scale[Rate],0,-1)-XLOOKUP(B2,Scale[Threshold],Scale[Deduction],0,-1)

For B2 = 102,520: the selected threshold is 100,000.01 (the next smaller value), the rate is 34%, and the deduction is 22,000, giving 102,520 × 34% - 22,000 = MAD 12,856.80 — the exact result of the step-by-step calculation. The same pattern works for a sales commission grid, a rebate schedule or a depreciation rate table. The advantage: when the scale changes, you update the table, not the formulas.

Building an aged receivables balance step by step

  1. Prepare the data: one row per invoice (customer, number, due date, amount). Convert the range into an Excel Table (Ctrl+T) and name it “Receivables”.
  2. Calculate days overdue: =IF(TODAY()>[@DueDate],TODAY()-[@DueDate],0).
  3. Create the bracket table (see above) and name it “Brackets”.
  4. Assign the bracket: =XLOOKUP([@Overdue],Brackets[Start],Brackets[Label],"",-1).
  5. Summarise: insert a PivotTable with customers in Rows, brackets in Columns and the sum of amounts in Values.
  6. Reconcile: the grand total of the table must equal the customer control account balance in the general ledger.

Expected output: for each customer, the amounts not yet due, 1 to 30 days overdue, 31 to 60 days, 61 to 90 days and over 90 days. This ageing schedule is the foundation for credit collection and estimating provisions for doubtful debts (see the article on doubtful debts).

The most recurring errors

Error or symptom Probable cause Fix
#N/A everywhere Key not found (text/number mismatch, extra space, typo) TEXT, TRIM, VALUE, or an “if not found” fallback
#VALUE! Mismatched array lengths in XLOOKUP Check that lookup and return arrays have the same row count
#NAME? Function unsupported in that Excel version Switch to INDEX + MATCH
Wrong result with no error Approximate match on unsorted column (MATCH type 1, VLOOKUP without FALSE) Use exact match or sort the table
Shifted result Range slides because $ is missing Lock references or use structured Table names
Slow workbook Tens of thousands of VLOOKUPs across large ranges Use Excel Tables or merge in Power Query

A sound control habit: add a check cell =COUNTIF(result_column,"Unknown account") to count unmatched keys. Any non-zero result should be resolved before proceeding.

A formula-free alternative: Power Query

To merge a 100,000-line general ledger with a chart of accounts, thousands of lookup formulas slow down the workbook. Power Query offers a cleaner route: Data > Get Data > Combine Queries > Merge. Select both tables, pick the shared key column, choose the join kind (Left Outer to keep every general ledger row) and expand the required columns. The result updates in one click (Refresh All). This is the recommended workflow for monthly trial balances exported from the same accounting package: build the query once and reuse it every month.

Pre-delivery workbook checklist

  • Reference tables are formatted as named Excel Tables.
  • Every lookup specifies an explicit “if not found” fallback.
  • A control cell counts unmatched keys.
  • Key formats are consistent (all text or all numbers).
  • Duplicates in the reference table have been removed.
  • Totals are reconciled against an independent source (trial balance, general ledger).
  • The recipients’ Excel version supports the chosen function.

Going further

In Excel 365, XLOOKUP (known as RECHERCHEX in French-language Excel) pairs with FILTER to return all rows matching a given criterion. For large datasets, Power Query (merging queries) effectively replaces thousands of lookup formulas.

Special cases and edge situations

Keys differ in upper and lower case. XLOOKUP is case-insensitive by default; for a case-sensitive lookup, use EXACT inside an array formula or normalise keys with UPPER.

Multiple rows share the same key. Only the first match (or the last with search mode -1) is returned. To retrieve every matching row, use FILTER or a PivotTable.

The reference table is in another workbook. External links work, but break if files are moved. Prefer importing the table with Power Query or keeping a copy inside the working file.

The expected result is numeric, but the cell returns text. Wrap the formula in VALUE or adjust the format of the result column, then verify with a control total.

The workbook must run on an older version of Excel. Replace XLOOKUP with INDEX and MATCH: the formula stays readable and compatible with every version.

Key takeaways

XLOOKUP is the modern lookup function: key on the left or right, built-in fallback value, reverse search for the last item, and approximate matching. INDEX and MATCH remain the universally compatible alternative. VLOOKUP should be avoided in new workbooks. In all cases, monitor unmatched keys.

Summary

A clean reference table (unique keys, uniform formats), a lookup function matched to your Excel version, an explicit fallback value and a control cell counting missing keys: four habits for dependable workbooks.

Frequently asked questions

XLOOKUP is not available in my version of Excel. What should I do?

XLOOKUP is available from Excel 2021 and Microsoft 365 onwards. On an earlier version, use =IFERROR(INDEX(return_array,MATCH(lookup_value,lookup_array,0)),“Not found”), which works identically.

Why do I get #N/A?

The value does not exist in the lookup range, or differs due to a space, format (text vs number) or case mismatch. Clean the data (TRIM, VALUE, TEXT) or provide a fallback value using the if_not_found argument.

What happens if there are duplicates in the key column?

XLOOKUP returns the first match by default (search_mode = 1 from top to bottom, -1 from bottom to top). If duplicates are errors, detect them with conditional formatting or COUNTIF.

How do I look up across multiple criteria?

Concatenate the criteria into a key column (account & “|” & period) or use XLOOKUP with calculated arrays (A:A&B:B). Another option is FILTER (Excel 365) or SUMIFS for a numeric result.

El Arabi Aich

Article written from the official texts and the firm’s engagement practice. It shows its publication date and, where applicable, its last review.

Related articles

A question about your situation?

Tell us about your project: we reply within 48 business hours with a draft engagement letter.