How to use Wildcards * and ? in Excel
Wildcards let a condition match part of a text. * stands for any number of characters, ? for exactly one. They work in COUNTIF, SUMIF, AVERAGEIF, their -IFS versions, VLOOKUP, MATCH and XLOOKUP (with match mode 2).
Syntax
=COUNTIF(range, "*text*")
"*text*" | Contains the text anywhere. |
"text*" | Starts with the text. |
"*text" | Ends with the text. |
"??-2026" | Exactly two characters, then -2026. |
"~*" | A real asterisk: the tilde turns the wildcard off. |
Examples
=COUNTIF(A2:A500, "*phone*")Products with "phone" anywhere in the name.=SUMIF(A2:A500, "Laptop*", B2:B500)Units of every product that starts with Laptop.=COUNTIF(A2:A500, "*"&E1&"*")Contains whatever is typed in E1.=VLOOKUP("*Ltd*", A2:C500, 3, FALSE)The first client whose name contains Ltd.Contains, starts with, ends with
Most text in real data isn't clean: "Elm Studio Ltd", "ELM STUDIO", "Elm Studio (old)". Wildcards match the part that matters.
=COUNTIF(B2:B500, "*Ltd*")Every client with Ltd in the name.=SUMIF(A2:A500, "INV-2026*", C2:C500)Every invoice number that starts with INV-2026.=COUNTIFS(B2:B500, "*loan*", D2:D500, "Open")Open products with loan in the description.A search box for a report
Join the wildcards to a cell, and the formula follows whatever someone types there.
=COUNTIF(B2:B500, "*"&$F$1&"*")How many rows contain the text in F1.=XLOOKUP("*"&$F$1&"*", B2:B500, C2:C500, "None", 2)The first match for the text in F1 (match mode 2 turns wildcards on).Common mistakes
- Wildcards in an = comparison
=A2="*phone*"compares with the literal text. Use COUNTIF orISNUMBER(SEARCH("phone", A2))instead.- Numbers don't match
- Wildcards work on text only.
"12*"won't find the number 1250. - Searching for a real * or ?
- Put a tilde in front:
"~?".
Frequently asked questions
What wildcards can I use in Excel?
* for any number of characters, ? for exactly one, and ~ in front of * or ? to search for the character itself.
Which functions accept wildcards?
COUNTIF, SUMIF, AVERAGEIF and their -IFS versions, VLOOKUP, HLOOKUP, MATCH, SEARCH, and XLOOKUP with match mode 2.
Why doesn't my wildcard work with =?
A normal comparison like =A2="*Ltd*" doesn't understand wildcards. Use =COUNTIF(A2, "*Ltd*")>0 or =ISNUMBER(SEARCH("Ltd", A2)).
Are wildcards case-sensitive?
No. "*phone*" matches iPhone, PHONE and phone.
Available in: All versions of Excel, Excel for the web, Google Sheets