Complete Guide to the MATCH Function: Exact, Approximate, Wildcard, and INDEX Combinations

MATCH function

Complete Guide to the MATCH Function: Exact, Approximate, Wildcard, and INDEX Combinations

The MATCH function returns the relative position (index) of a value within a specified range. Use it when you need the position rather than the value itself, typically in combination with INDEX to retrieve the desired value. (Official definition)

Quick Fix (2 Minutes): Find a Position Instantly with an Exact Match

  1. Select the list range: for example, A2:A8
  2. Lookup value: for example, E2 (customer name)
  3. Formula (exact match): =MATCH(E2, $A$2:$A$8, 0)
  4. Combine with INDEX (return a value): =INDEX($B$2:$B$8, MATCH(E2, $A$2:$A$8, 0))

Concepts and Syntax Overview

=MATCH(lookup_value, lookup_array, [match_type])
  • lookup_value: The value to find (number, text, or date)
  • lookup_array: The range to search (a row or column)
  • match_type: 0=exact match, 1=next largest value (requires ascending order), -1=next smallest value (requires descending order)

Three match_type Options: Selection Guide

  • 0 (exact): No sorting required; wildcards are supported (*, ?, ~)
  • 1 (approximate—next largest value): Ascending sort required
  • -1 (approximate—next smallest value): Descending sort required

Using Wildcards (Only in 0 Mode)

  • *: Any string of zero or more characters; ?: any single character; ~: escapes a wildcard character
  • Example: =MATCH("Kim*", $A$2:$A$100, 0) — the first position that starts with “Kim”

Six Practical Examples (Reproducible)

1) Find a Name’s Position (Exact)

NameDept
J.KimSales
A.LeeHR
M.ParkFinance
S.ChoiSales

=MATCH("M.Park", $A$2:$A$5, 0) → returns 3.

2) Find a Price Tier (Approximate, Ascending)

Discount table based on purchase quantity (ascending): 1, 10, 50, 100…

=MATCH(H2, $B$2:$B$10, 1)

For the quantity in H2, returns the position of the value equal to or immediately below the next largest value → use INDEX to return the unit price.

3) Partial Match with Wildcards

=MATCH("*-KR", $D$2:$D$50, 0)

The first position of an SKU ending in “-KR.”

4) Return a Value with INDEX+MATCH (Left or Right Lookup)

=INDEX($C$2:$C$100, MATCH(H4, $A$2:$A$100, 0))

The lookup key can be on either the left or right because the return range and lookup range are separate.

5) Two-Way Lookup (Row and Column Intersection)

=INDEX($C$5:$G$12, MATCH(H6, $B$5:$B$12, 0), MATCH(H7, $C$4:$G$4, 0))

Uses MATCH to find the row key (H6) and column key (H7), then returns the value at their intersection.

6) Find the “Last Value” Index (Duplicate Keys)

=MAX(IF($A$2:$A$100=H8, ROW($A$2:$A$100)-ROW($A$2)+1))

An array formula (in dynamic array environments, press Enter). Use the position of the last match with INDEX.

Troubleshooting (Symptom | Cause | Solution)

SymptomCauseSolution
#N/AValue missing or misspelled; number-to-text format mismatchStandardize formats (numbers as numbers), use TRIM/CLEAN, and use VALUE/TEXT if needed
Incorrect result (approximate)Sort requirement violated (ascending/descending mismatch)Follow the match_type rules: 1 (ascending) and -1 (descending), and sort the list
Unexpected positionWildcard or case-sensitivity confusionUse wildcards only in 0 mode; MATCH is not case-sensitive
Error when combined with INDEXReturn range height or width does not matchVerify that the length of the INDEX return range matches the MATCH lookup range

MATCH vs. XMATCH & XLOOKUP

  • MATCH: Returns only a position. Approximate matching requires sorted data (ascending=1, descending=-1), and wildcards are supported in 0 mode.
  • XMATCH: Exact match by default, with reverse search (-1) and binary search (±2) → useful for large datasets and duplicates.
  • XLOOKUP: Returns the value itself and lets you directly control reverse or binary search with search_mode.

Checklist (Avoid Mistakes)

  • Exact match (0) does not require sorting; approximate match (±1) does.
  • Wildcards work only in 0 mode (*, ?, ~).
  • When combining with INDEX, lookup range length = return range length.
  • For duplicate keys, consider a helper formula or XMATCH (search_mode=-1) when you need the last match.

Related Posts

Official definitions and notes: Microsoft Support (MATCH/XLOOKUP/XMATCH). Practical recipes: Exceljet.

Leave a Reply

Your email address will not be published. Required fields are marked *