How to Use the MATCH Function in Excel
In this article
The MATCH function in Excel finds the position of a specified item within a range or array. It returns a number (e.g., 1, 2, 3) indicating where the match occurs—starting from the first cell in the range. You need a lookup value and a known range to search; no add-ins or special setup required.
What You'll Need
- A value to search for (the lookup_value)
- A range of cells containing possible matches (the lookup_array)
- Basic knowledge of Excel cell references (e.g., A1:A10)
Step-by-Step
- Open your Excel workbook and ensure your data is organized in a single column or row. MATCH works best with one-dimensional ranges (e.g., A1:A20 for a column or A1:E1 for a row).
- Click the cell where you want the result to appear (e.g., C2).
- Enter the formula:
=MATCH(lookup_value, lookup_array, [match_type]). Replace each part: - lookup_value: The item you want to find (e.g., "Apple", 42, or a cell reference like B1).
- lookup_array: The range where Excel should search (e.g., A1:A100). Use absolute references (e.g., $A$1:$A$100) if copying the formula down or across.
- match_type: Optional. Use 0 for an exact match (most common), 1 for the largest value ≤ lookup_value (requires sorted ascending data), or -1 for the smallest value ≥ lookup_value (requires sorted descending data). Always use 0 unless you specifically need approximate matching.
- Press Enter. Excel will return the relative position of the first match within the range. For example, if "Apple" appears in cell A5 and your range is A1:A10, MATCH returns 5 (because A5 is the 5th cell in A1:A10).
- To verify, test with a simple case: In A1:A3, enter "Red", "Green", "Blue". In B1, type
=MATCH("Green", A1:A3, 0). Press Enter—Excel returns 2.
Common Mistakes
- Using unsorted data with match_type 1 or -1: If you omit match_type (defaults to 1) or set it to 1/-1, your data must be sorted. Using it with unsorted data causes incorrect results or #N/A errors.
- Ignoring case sensitivity: MATCH is not case-sensitive. Searching for "apple" finds "Apple", "APPLE", etc. If case matters, use INDEX/MATCH with EXACT or consider VBA.
- Partial matches with wildcards: When match_type is 0, Excel supports wildcards (* and ?). Typing
=MATCH("Ap*", A1:A10, 0)finds "Apple". But if your data contains literal asterisks or question marks, precede them with a tilde (e.g.,"~*"). - Off-by-one errors: MATCH returns position within the range—not the row number on the sheet. If your range starts at A5 (e.g., A5:A15) and "Target" is in A7, MATCH returns 3 (A7 is the 3rd cell in A5:A15), not 7.
- Using multi-dimensional ranges: MATCH only works in one row or one column. If you select A1:C10, Excel returns #N/A. Always limit lookup_array to a single row or column.
Tips
- Combine with INDEX: MATCH alone gives position, but MATCH + INDEX retrieves the actual value (e.g.,
=INDEX(B1:B10, MATCH("Apple", A1:A10, 0))gets the price for "Apple"). This is more flexible than VLOOKUP. - Use named ranges: Name your lookup range (e.g., "ProductList"), then write
=MATCH("Apple", ProductList, 0). This makes formulas easier to read and maintain. - Handle errors gracefully: Wrap MATCH in IFERROR to show a friendly message instead of #N/A:
=IFERROR(MATCH("Apple", A1:A10, 0), "Not found"). - Check for hidden spaces or formatting: Leading/trailing spaces (e.g., " Apple " vs "Apple") cause mismatches. Use TRIM() or CLEAN() to clean data first.
- Sort data only for approximate matches: If you need approximate matching (e.g., tax brackets), sort ascending for match_type 1 or descending for -1—but this is rare. Default to 0 for most tasks.
Troubleshooting
If MATCH returns #N/A, follow these checks:
- Verify the value exists: Manually scan the range for the lookup_value. Check for extra spaces (use TRIM), different capitalization (unlikely to matter), or typos.
- Confirm match_type is 0: If you omitted it, Excel assumes 1. Explicitly add ,0 at the end of the formula.
- Ensure the range is one-dimensional: Double-click the formula bar, highlight lookup_array, and verify it’s a single row or column.
- Test with a known value: Replace lookup_value with a value you know is in the range (e.g.,
=MATCH(A1, A1:A10, 0)if A1 is in the list). - Check for errors in referenced cells: If lookup_value is a cell (e.g., B1), ensure B1 doesn’t contain #N/A or text like “#VALUE!”.
- Look for non-printing characters: Copy your data to Notepad, then paste back into Excel to strip hidden characters.
If MATCH returns #REF! or #NAME?, check for typos in the function name or broken cell references (e.g., deleted columns). Restart Excel if formulas behave erratically—rare, but sometimes fixes temporary glitches.
Frequently Asked Questions
Does MATCH work across multiple rows and columns?
No. MATCH only searches a single row or column. For 2D lookups (e.g., finding a value at the intersection of a row and column), combine MATCH twice: one for the row position and one for the column position, then use INDEX to retrieve the cell.
Can MATCH find all matches, not just the first one?
No. MATCH stops after the first match. To list all matches, use FILTER (in Excel 365) or combine INDEX, ROW, and IFERROR in an array formula. For example: =IFERROR(INDEX($A$1:$A$10, SMALL(IF($A$1:$A$10=$B$1, ROW($A$1:$A$10)-ROW($A$1)+1), ROW(1:1))), "") (entered with Ctrl+Shift+Enter in older Excel).
How is MATCH different from VLOOKUP?
MATCH returns only the position (a number), while VLOOKUP returns the value from a specified column. MATCH is more flexible: it works left-to-right or right-to-left, and its lookup_array can be any single row/column. VLOOKUP requires the lookup column to be leftmost and has limited error handling.
Why does MATCH give 0 when the value is missing?
It never does. If no match is found, MATCH returns #N/A. A result of 0 means your lookup_array is empty or contains only blanks. Double-check your range and ensure cells aren’t formatted as text with invisible spaces.
Does MATCH work with dates?
Yes—Excel stores dates as serial numbers. Use the same date format in lookup_value and the range. For reliability, enter dates as =DATE(2024,5,15) or use cell references (e.g., MATCH(C1, A1:A10, 0) where C1 contains a valid date).
Can I use MATCH with tables (structured references)?
Yes. If your data is in an Excel Table (Ctrl+T), use table column names: . This auto-adjusts if rows/columns are added or removed.