If your Excel SUMIF formula with wildcards isn't returning the expected result, it's usually due to incorrect syntax, data formatting issues, or mismatched criteria ranges. Wildcards like asterisk (*) and question mark (?) are powerful for partial matching, but they only work when used correctly within text-based criteria. This guide shows you how to diagnose and fix common SUMIF wildcard failures with precise, tested steps.
What You'll Need
- Microsoft Excel (2010 or later)
- A dataset with text values in a column you want to sum by partial match
- A separate column containing numeric values to sum
- Basic understanding of Excel cell references and ranges
Step-by-Step
- Identify the column containing the text criteria (e.g., product names like "Apple iPhone 12", "Apple iPad Air") and the column with numeric values to sum (e.g., sales figures). Ensure the text column contains actual text, not numbers formatted as text.
- Confirm your SUMIF syntax:
=SUMIF(range, criteria, [sum_range]). The criteria must be enclosed in quotes when using wildcards. For example, to sum all sales for products starting with "Apple", use=SUMIF(A2:A100, "Apple*", B2:B100). - Check for leading or trailing spaces in your criteria column. Use the TRIM function on a helper column:
=TRIM(A2)and copy down. Then update your SUMIF to reference the cleaned column instead of the original. - Test the wildcard pattern manually. In an empty cell, enter
=ISNUMBER(SEARCH("Apple", A2))for one sample row. If it returns FALSE, the text doesn’t contain "Apple" as expected—this reveals hidden characters or case mismatches. - Use double quotes around the entire criteria string. Never write
Apple*without quotes. Excel treats unquoted text as a cell reference, not a literal string. Always use"Apple*". - If matching middle text, use asterisks on both sides:
"*iPhone*"to find any cell containing "iPhone" anywhere in the text. - If matching a single character, use the question mark:
"A??le"matches "Apple" or "Auple" but not "Aaple" or "Apples". - Verify that your sum_range is the same size and shape as your criteria_range. If criteria is A2:A100, sum_range must be B2:B100 (not B2:B99 or B1:B100).
- Ensure you’re not accidentally referencing merged cells or non-contiguous ranges. SUMIF requires contiguous, rectangular ranges.
- Replace wildcards with exact matches temporarily. Change
"Apple*"to"Apple iPhone 12"and see if SUMIF works. If it does, your wildcard logic is the issue, not the formula structure.
Common Mistakes
- Forgetting to enclose wildcard criteria in double quotes (e.g., writing
Apple*instead of"Apple*") - Using wildcards on numeric data—SUMIF wildcards only work on text values. If your criteria column contains numbers, convert them to text first using
TEXT(A2,"0")or by prefixing with an apostrophe. - Assuming case-sensitivity: SUMIF is not case-sensitive. "apple" and "Apple" are treated the same. If you need case-sensitive matching, use SUMPRODUCT with EXACT instead.
- Typing the wildcard inside a cell reference instead of as a literal string (e.g.,
=SUMIF(A2:A100, C1&"*", B2:B100)is fine if C1 contains "Apple", but=SUMIF(A2:A100, C1*, B2:B100)is invalid syntax) - Using wildcards with numeric criteria ranges—wildcards have no meaning when applied to numbers, so the formula may return 0 or #VALUE!.
Tips
- Use the ampersand (&) to combine cell content with wildcards dynamically:
=SUMIF(A2:A100, C1&"*", B2:B100)where C1 contains the partial text you want to match. - For multiple partial matches, use SUMIFS with multiple criteria, or nest multiple SUMIF functions using + operators:
=SUMIF(A2:A100,"Apple*",B2:B100) + SUMIF(A2:A100,"Samsung*",B2:B100) - Use Find and Replace (Ctrl+H) to check for invisible characters like non-breaking spaces (Alt+255) or carriage returns. Replace them with nothing.
- Format your criteria column as "Text" before entering data to prevent Excel from auto-converting entries like "123ABC" to numbers.
- Apply conditional formatting to highlight cells matching your wildcard pattern using a formula like
=ISNUMBER(SEARCH("Apple",A2))to visually validate your logic before writing SUMIF.
Troubleshooting
If SUMIF still returns 0 or an error after following the steps above:
- Check for #VALUE! errors in the criteria or sum range. These occur if any cell contains text where a number is expected in the sum_range. Use =ISNUMBER(B2) on your sum_range to identify non-numeric cells.
- Verify there are no hidden characters. Copy a sample cell from your criteria column into Notepad or Notepad++. If you see extra spaces or symbols, they’re the culprit. Use CLEAN(A2) to remove non-printable characters.
- Test with a simplified dataset: create a new worksheet with 5 rows of sample data (e.g., A1:A5 = "Apple 1", "Apple 2", "Banana", "Apple 3", "Orange" and B1:B5 = 10, 15, 20, 25, 30). Use
=SUMIF(A1:A5,"Apple*",B1:B5). If it works here, your original data has formatting issues. - Ensure your Excel calculation mode is set to Automatic (Formulas > Calculation Options > Automatic). Manual mode can prevent formulas from updating.
- Check for circular references or formula errors elsewhere on the sheet that may be disrupting calculation flow.
- If you're using Excel Online or an older version, some wildcard behaviors may differ slightly. Try the same formula in desktop Excel.
Frequently Asked Questions
Why does SUMIF return 0 even when the text matches?
Most likely, your criteria column contains numbers instead of text. SUMIF wildcards work only on text. Convert numbers to text using TEXT() or format the column as Text before entering data.
Can I use wildcards with SUMIFS?
Yes. SUMIFS supports wildcards the same way as SUMIF. Use =SUMIFS(sum_range, criteria_range1, "*text*", criteria_range2, "value").
Do wildcards work in Excel Online?
Yes, but only in the desktop version of Excel Online. The web app supports basic wildcards, but complex patterns may behave differently. Test in desktop Excel if results are inconsistent.
Why does "?" not match a single character as expected?
The question mark matches exactly one character. If your text has two characters where you expect one, it won’t match. For example, "A?le" won’t match "Apple" because there are two characters between "A" and "le".
Can I use wildcards to match partial numbers?
No. Wildcards only work on text strings. If your data is numeric (e.g., 12345), convert it to text first with TEXT(A2,"0") before applying wildcards.
What if my criteria contains an asterisk or question mark?
To match a literal asterisk or question mark, precede it with a tilde: ~* or ~?. For example, to find cells containing "Price: $10*", use "Price: $10~*".