COUNTIF with wildcards

Counting · About 5 minutes

COUNTIF with wildcards

Sometimes you want to count cells that only partly match. A wildcard is a symbol that stands in for other characters.

Exercise 1 of 4 · Worked example

In B9, count the items made of cotton. Type =COUNTIF(A2:A7,"Cotton*") and press Enter.

AB
1ItemCode
2Cotton kurtaKUR-101
3Silk sareeSAR-12
4Cotton sareeSAR-140
5Linen shirtSHI-205
6Silk kurtaKUR-37
7Cotton dupattaDUP-118
8
9Cotton items (answer cell)

Questions people ask

How do I count cells that contain specific text?

Put * on both sides: =COUNTIF(A2:A50,"*tea*") counts every cell with "tea" anywhere in it.

How do I count cells that do not contain a word?

Put <> before the pattern: =COUNTIF(A2:A50,"<>*tea*").

What do * and ? mean in COUNTIF?

* stands for any number of characters, including none. ? stands for exactly one, so "???" matches any three-character text.

Why doesn't my wildcard match numbers?

Wildcards only match text. A code stored as a number, like 1045, is skipped by "10*".

How do I count cells that contain an actual asterisk?

Put a tilde before it: "*~**" counts cells that contain *.

Theme