Ravindra BagaleCourses & study guides Track your progress

Excel XMATCH Function

Chala mitrano — xMATCH is MATCH with seatbelts: wildcards, reverse search, and clearer modes. Still returns a position, not the final value.

Fictional sample data for learning. Helpdesk ticket queue (Kochi / Toronto). Mixed ₹ and CA$ credits.

Purpose

Find the position of a value with modern options: exact, wildcard, next-smaller/larger, and search last-to-first.

Return value

1-based position inside the lookup array, or #N/A / if_not_found behaviour when wrapped.

Syntax

XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])

Arguments

ArgumentRequired?Description
lookup_valueRequiredValue to find.
lookup_arrayRequiredOne row or one column to search.
match_modeOptional0 exact (default), -1 exact or next smaller, 1 exact or next larger, 2 wildcard.
search_modeOptional1 first-to-last (default), -1 last-to-first, 2 binary asc, -2 binary desc.

Version

Microsoft 365 and Excel 2021. Not in Excel 2019 or older. LibreOffice: may be missing — use MATCH as fallback.

How to use — Why → What → How

Why: Queues and logs need “where is the latest ticket for this ID?” not only the first. XMATCH is the modern position finder: exact by default, wildcards with match_mode 2, and search_mode -1 for the last match — perfect when Ananya appears twice in a Kochi helpdesk l...

What: XMATCH returns the position of lookup_value using the match and search modes you choose. Read the arguments table carefully; each one changes the answer in a specific way.

How — numbered steps:

  1. Type =XMATCH(.
  2. Select the value to find.
  3. Select the key column.
  4. Optionally set match_mode (0 or 2) and search_mode (-1 for last).
  5. Enter, then wrap with INDEX if you need the value.
  6. Compare your result with the Answers sheet only after you attempt it.
  7. Write one sentence in your own words explaining when you would use this function at work.

Ravindra Bagale's Tip

Friends, search_mode -1 is perfect when the same customer appears twice and you want the latest row’s position.

Ravindra Bagale's Tip

On Excel 2019 use MATCH instead. Keep a fallback note in shared workbooks.

Ravindra Bagale's Tip

Friends, after class open a blank sheet and rebuild one XMATCH example without looking. That memory test beats re-reading the page.

Download practice file: practice-xmatch.xlsx (includes sheet About this data, practice sheets, and Answers).

Worked examples

1) Exact position

Kochi helpdesk tickets.

TicketAgentCredit (₹)
T-21Ananya200
T-25Ravi0
T-29Ananya150
Formula: =XMATCH("T-25", A2:A4)

Result: 2

What it means: Default exact match; T-25 is position 2.

2) Last match with search_mode -1

Ananya appears twice; take the last ticket position.

AgentTicket
AnanyaT-21
RaviT-25
AnanyaT-29
Formula: =XMATCH("Ananya", A2:A4, 0, -1)

Result: 3

What it means: Search from the bottom → position 3.

3) Wildcard match_mode 2

Find first ticket starting with T-2.

Ticket
T-19
T-21
T-25
Formula: =XMATCH("T-2*", A2:A4, 2)

Result: 2

What it means: Wildcard mode; T-21 is first T-2*.

4) INDEX + XMATCH city

Toronto row with CA$ note.

TicketCityNote
T-21Kochi₹200
T-40TorontoCA$15
T-29Kochi₹150
Formula: =INDEX(B2:B4, XMATCH("T-40", A2:A4))

Result: Toronto

What it means: XMATCH finds position 2; INDEX returns City.

5) Missing ID

T-99 not in list.

Ticket
T-21
T-25
Formula: =XMATCH("T-99", A2:A3)

Result: #N/A

What it means: No match → #N/A; wrap with IFNA in reports.

6) Classroom recap

Quick check before you close the XMATCH lesson.

TicketAgentCredit (₹)
T-21Ananya200
T-25Ravi0
T-29Ananya150
Formula: =XMATCH("T-25", A2:A4)

Result: 2

What it means: Same pattern as example 1 — rebuild it from memory on the Practice sheet, then check Answers.

Common errors and fixes

#N/A — No match. Fix: Fix the key or wrap with IFNA.
#VALUE! — lookup_array is not a single row/column. Fix: Pass one row or one column.
#NAME? — Excel version too old for XMATCH. Fix: Use MATCH, or upgrade to 365/2021.

Notes and tips

  • Binary search modes need sorted data.
  • XMATCH does not have if_not_found — use IFNA around it.
  • Prefer XLOOKUP when you need the value directly.
  • XMATCH is the modern position finder: exact by default, wildcards with match_mode 2, and search_mode -1 for the last match — perfect when Ananya appears twice in a Kochi helpdesk log and you need the latest ticket row. It still returns a position; wrap with INDEX (or prefer XLOOKUP) when you need the value. Excel 2019 users must fall back to MATCH.
  • Use XMATCH when you need a position with modern modes; use XLOOKUP when you need the matching value directly.
  • Fictional sample data only — practice amounts and names are made for learning.
  • After you finish the 10 tasks, re-read the errors table once; most class mistakes are listed there.
  • Keep ranges locked with absolute references when you copy formulas down a column of inputs.
  • Say the business question in plain words before you type the equals sign — it prevents wrong arguments.

In real work

XMATCH is the modern position finder: exact by default, wildcards with match_mode 2, and search_mode -1 for the last match — perfect when Ananya appears twice in a Kochi helpdesk log and you need the latest ticket row. It still returns a position; wrap with INDEX (or prefer XLOOKUP) when you need the value. Excel 2019 users must fall back to MATCH.

How it compares

Use XMATCH when you need a position with modern modes; use XLOOKUP when you need the matching value directly.

Interview corner

How do you get the last match position?
search_mode -1.
Does XMATCH have if_not_found?
No — wrap with IFNA.
Minimum Excel version?
Microsoft 365 or Excel 2021.

MATCH, XLOOKUP, INDEX, FILTER

Practice tasks (10)

  1. Task 1. Find position of T-25.
    Hint: default modes are fine.
  2. Task 2. Find last position of agent Ananya.
    Hint: search_mode -1.
  3. Task 3. Wildcard: first ticket like T-2*.
    Hint: match_mode 2.
  4. Task 4. Return City for T-40 with INDEX+XMATCH.
    Hint: XMATCH inside INDEX.
  5. Task 5. Show Missing for T-99 via IFNA.
    Hint: wrap XMATCH.
  6. Task 6. Compare MATCH vs XMATCH for the same ID.
    Hint: both should agree on exact mode.
  7. Task 7. Explain when you need XLOOKUP instead.
    Hint: when you want the value, not the position.
  8. Task 8. Use a cell reference as lookup_value.
    Hint: point at the ticket cell.
  9. Task 9. Document the Excel version note for your team.
    Hint: 365/2021 only.
  10. Task 10. Bonus: return Credit for the last Ananya ticket.
    Hint: INDEX + XMATCH with search_mode -1.

Quick quiz

Q1. XMATCH returns a value from another column.
Q2. search_mode -1 means:
Q3. Wildcard matching uses match_mode:
Q4. XMATCH is in Excel 2016 by default.
Q5. To get the city after XMATCH you often use:

Answers: Q1=False, Q2=Last match, Q3=2, Q4=False, Q5=INDEX (check after you try).

Revision card

Standalone card (no tip or photo strip). QR opens this lesson. Download the PNG and revise offline.

Revision card: XMATCH
XMATCH revision card