The SUMIF, COUNTIF with wildcards guide
In a condition, * stands for any run of characters and ? for exactly one. =SUMIF(A2:A13, "4*", C2:C13) adds the accounts that start with 4; =COUNTIF(B2:B13, "*refund*") counts the memos with refund anywhere in them.
Starts with, contains, ends with
"4*": starts with 4. "4010 Product sales" yes, "5410 Travel" no."*refund*": refund anywhere. "Partial refund from supplier" yes."*refund": ends with refund."INV-22??": INV-22 and exactly two more characters.
Without a *, the condition has to match the whole cell. Capitals don't matter. To look for a real asterisk, write ~*.
*4* is not "starts with 4"
On a chart of accounts, "*4*" catches every code with a 4 in it: 5410 Travel, 6400 Office supplies, 7400 Bank fees. The total looks plausible and is wrong. Say what you mean: "4*".
Wildcards only work on text
If the account codes are plain numbers, like 4010, "4*" finds nothing: wildcards don't match numbers. Use a range instead, =SUMIFS(C2:C13, A2:A13, ">=4000", A2:A13, "<5000"). The reverse fails too: a number test like ">=4000" never matches "4010 Product sales", which is text.
A word from a cell
Join the wildcards to a cell: =COUNTIF(B2:B13, "*"&F1&"*") counts the memos that contain whatever is in F1. See a condition in a cell.
FAQ
- How do I use a wildcard in SUMIF?
- Put * or ? inside the condition in quotes: =SUMIF(A2:A13,"4*",C2:C13) adds the rows whose A cell starts with 4. * means any characters, ? exactly one.
- How do I count cells that contain a word in Excel?
- Use =COUNTIF(range,"*word*"). The asterisks on both sides find the word anywhere in the cell, in any capitals.
- Why does my SUMIF wildcard return 0?
- Usually the cells hold numbers, and wildcards only match text. Use a range condition such as ">=4000" and "<5000" with SUMIFS instead.
- How do I search for an actual asterisk with COUNTIF?
- Put a tilde in front of it: "~*". The same goes for a question mark: "~?".
This task is in the timed accounting practice test. What Excel interview tests check






























































