Excel IF Match Formula? How to Use It
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
The Excel IF match formula combines the IF function with a matching function (such as MATCH, VLOOKUP, or COUNTIF) to return a result only when a value is found in a list or range. You enter the lookup value, the range to search, and the value to return if found (and optionally if not found), and the formula gives you a custom output like “Yes”/”No” or a label.
Formula
The most common form uses IF with MATCH:
=IF(ISNUMBER(MATCH(lookup_value, lookup_array, 0)), value_if_found, value_if_not_found)
- lookup_value – the value you want to find (text, number, or cell reference).
- lookup_array – the range of cells to search (e.g., A2:A100).
- 0 – exact match (required for most uses).
- value_if_found – what to return if MATCH finds the value.
- value_if_not_found – what to return if MATCH does not find it.
MATCH returns a number (the position) when found, and #N/A when not found. ISNUMBER converts that into TRUE/FALSE, which IF can evaluate.
Worked Example
Suppose you have a list of product codes in cells A2:A10, and you want to check if code “X-100” exists. You want “Found” if it does, “Missing” if not.
- Enter the formula in cell B2:
=IF(ISNUMBER(MATCH("X-100", A2:A10, 0)), "Found", "Missing") - MATCH(“X-100”, A2:A10, 0) returns a number like 3 if found, or
#N/Aif not. - ISNUMBER(3) = TRUE, so IF returns “Found”.
- If not found, ISNUMBER(#N/A) = FALSE, so IF returns “Missing”.
If your list contains “X-100” in cell A5, the result is “Found”. If not, “Missing”.
Why Use IF with MATCH Instead of VLOOKUP?
VLOOKUP returns a value from another column, but it cannot simply tell you if a value exists without returning an error. IF+MATCH is cleaner for existence checks because it directly returns TRUE/FALSE logic. It is also faster on large datasets than COUNTIF in some cases, and it works with text, numbers, and wildcards.
MATCH also supports approximate matches (1 or -1) for ranges like grade boundaries or pricing tiers, which VLOOKUP can do but with more restrictions.
Common Variations and Related Formulas
- IF with COUNTIF:
=IF(COUNTIF(A2:A10, "X-100")>0, "Found", "Missing")– counts occurrences; works the same for existence. - IF with VLOOKUP and ISNA:
=IF(ISNA(VLOOKUP(...)), "Not Found", VLOOKUP(...))– returns the actual value if found. - Case-sensitive match: Use
EXACTinside an array formula, like=IF(SUMPRODUCT(--EXACT("x-100", A2:A10))>0, "Found", "Missing"). - Wildcards: MATCH supports wildcards (
*,?) when using 0, e.g.,MATCH("X-*", A2:A10, 0).
How to Choose Between MATCH, COUNTIF, and VLOOKUP
- MATCH + ISNUMBER – fastest for a simple yes/no existence check, especially on large ranges.
- COUNTIF – also simple, but counts duplicates; if you need to know how many times it appears, use this.
- VLOOKUP/INDEX+MATCH – when you need to return a value from another column, not just existence.
- XLOOKUP (Excel 365/2021) – can handle not-found directly with an
if_not_foundargument, so you may not need IF at all.
Common Mistakes and How to Fix Them
- Using 1 instead of 0: MATCH with 1 requires sorted data; use 0 for exact match.
- Inconsistent ranges: If lookup_array is A2:A10, don’t put the result in a formula in row 1 that references A1 – it will return #N/A.
- Text formatting: Numbers stored as text won’t match numbers. Use
TEXTorVALUEto convert. - Leading/trailing spaces: Use
TRIMon both sides. - Case sensitivity: MATCH is not case-sensitive by default. Use EXACT if you need case-sensitive.
- Whole column references:
A:Aworks but may slow down; limit to the actual data range.
Limitations and When Not to Use
IF+MATCH only checks existence, not how many times a value appears. It also returns the first match position, so if you need all positions, you need an array formula or a different approach. For partial matches, wildcards can help, but they can also cause false positives (e.g., “X-*” matches “X-100” and “X-200”).
If you need to return multiple columns from a match, use INDEX+MATCH or XLOOKUP instead. And if your data is in a table, structured references can make formulas more readable.
Frequently Asked Questions
How do I use IF with MATCH to return a value from another column?
Use INDEX+MATCH: =IF(ISNUMBER(MATCH(lookup, range, 0)), INDEX(return_range, MATCH(lookup, range, 0)), "Not Found"). This returns the value from the return_range at the same position.
Why does my IF MATCH formula return #N/A instead of my “not found” message?
Because MATCH returns #N/A when not found, and ISNUMBER(#N/A) is FALSE, so IF should return the not-found value. If you see #N/A, you likely forgot ISNUMBER and are using =IF(MATCH(...), ...) – that evaluates the number, but #N/A is an error that propagates. Wrap it with ISNUMBER or use IFERROR.
Can I use IF with MATCH for partial text matches?
Yes, use wildcards: =IF(ISNUMBER(MATCH("*"&A1&"*", B2:B10, 0)), "Found", "Missing"). This matches any cell containing the text in A1.
Is there a difference between IF MATCH and IF COUNTIF?
Both check existence, but COUNTIF counts all occurrences, so it’s slightly slower on huge ranges. MATCH stops at the first match, so it’s faster. For simple existence, either works; for counting, use COUNTIF.
How do I make the formula case-sensitive?
Use =IF(SUMPRODUCT(--EXACT(lookup, range))>0, "Found", "Missing") as an array formula (or with SUMPRODUCT it works normally). EXACT compares case-sensitively.
What if I have multiple criteria to match?
Use COUNTIFS or SUMPRODUCT. For example, =IF(COUNTIFS(A:A,"X",B:B,"Y")>0, "Found", "Missing") checks if a row has both X and Y.
Related
Formula used
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.