ExcelReady
CourseFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before the interview. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Function guides
  • Blog

Product

  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. Excel Wildcards: *, ? and ~ in COUNTIF and SUMIF

Excel Wildcards: *, ? and ~ in COUNTIF and SUMIF

By ExcelReady Team·Updated October 30, 2026·7 min read

The short answer

Excel has three wildcard characters for criteria. An asterisk () matches any number of characters, so "CAB-" means starts with CAB-. A question mark (?) matches exactly one character. A tilde (~) before * or ? makes it a normal character. Use them inside quotes in COUNTIF, SUMIF, COUNTIFS and SUMIFS, for example =COUNTIF(A2:A9,"CAB-*").

Key takeaways

    • matches any number of characters, including none: "Cable" means contains Cable.
  • ? matches exactly one character: "MSE-30?" matches MSE-301 but not MSE-30.
  • ~ turns a wildcard into a normal character: "~" means ends with an asterisk.
  • Join wildcards to a cell with &: ""&H1&"" means contains whatever is in H1.
  • Wildcards only match text, not real numbers, and they ignore capitals.
On this page+
  1. What are the wildcard characters in Excel?
  2. How to use the * wildcard: starts with, ends with, contains
  3. How to use the ? wildcard for one character
  4. How to match a real * or ? with the tilde (~)
  5. How to combine wildcards with a cell reference
  6. Wildcards with COUNTIFS and SUMIFS
  7. When don't wildcards work?
  8. Practise it

An Excel wildcard is a symbol that stands for unknown characters, so your criteria can match part of the text instead of all of it. Use * for "any characters", ? for "exactly one character", and ~ when you need a real asterisk or question mark. This guide shows each one in COUNTIF, SUMIF and COUNTIFS on a small inventory table, and explains when wildcards won't work.

What are the wildcard characters in Excel?#

Excel has three wildcard characters, and they work inside the criteria of functions like COUNTIF and SUMIF:

WildcardMatchesExampleMatchesDoesn't match
*Any number of characters, even none"CAB-*"CAB-101, CAB-XCAB-1
?Exactly one character"MSE-30?"MSE-301MSE-30, MSE-3010
~Makes the next * or ? a normal character"*~*"Car Charger*Car Charger

Wildcards are not case-sensitive, so "cab-*" matches CAB-101 too. They always go inside the double quotes.

The examples use this inventory table in A1:D9:

ABCD
1SKUProductWarehouseStock
2CAB-101USB-C Cable 1mLeeds240
3CAB-102USB-C Cable 2mBristol85
4CHG-201Wall Charger 20WLeeds132
5CHG-202Car ChargerBristol18
6CAB-103HDMI Cable 2mLeeds64
7MSE-301Wireless MouseBristol47
8MSE-302Gaming MouseLeeds12
9CHG-203Wireless ChargerLeeds55

How to use the * wildcard: starts with, ends with, contains#

Where you put the asterisk decides what you match. After the text means "starts with", before it means "ends with", and on both sides means "contains".

QuestionFormulaResult
SKUs that start with CAB-=COUNTIF(A2:A9,"CAB-*")3
Products that start with Wireless=COUNTIF(B2:B9,"Wireless*")2
Products that end with 2m=COUNTIF(B2:B9,"*2m")2
Stock of products containing Charger=SUMIF(B2:B9,"*Charger*",D2:D9)205
Products that don't contain Cable=COUNTIF(B2:B9,"<>*Cable*")5

The Charger total is 132 + 18 + 55. Without the asterisks, "Charger" would only match a cell that says exactly Charger, and the result would be 0. The last row shows that <> works with wildcards too: it counts everything that does not match the pattern.

How to use the ? wildcard for one character#

A question mark stands for exactly one character, which is useful for codes with a fixed length. To count the mouse SKUs, which are MSE-30 plus one more character:

Excel formula
=COUNTIF(A2:A9,"MSE-30?")

The result is 2 (MSE-301 and MSE-302). "CHG-20?" gives 3. You can repeat it: "???-1*" means three characters, a dash, a 1, then anything, so it matches the three CAB-10x codes.

Quick reference: common wildcard patterns#

PatternMeansCount on the table
"*"Any text at all8
"???-???"Exactly three characters, a dash, three characters8
"W*"Starts with W3
"*Mouse"Ends with Mouse2
"*e*"Contains the letter e (any case)8

The first two count SKUs in column A; the others count products in column B. "*" only counts text, so it's a quick way to spot numbers hiding in a text column: compare it with COUNTA.

How to match a real * or ? with the tilde (~)#

Put a tilde before an asterisk or question mark when you mean the character itself. Say some product names end with an asterisk to mark discontinued items, like Car Charger*. To count them:

Excel formula
=COUNTIF(B2:B9,"*~*")

The first * is a wildcard (any characters) and ~* is a real asterisk. Without the tilde, "**" would match every text cell. In the same way, "*~?*" counts cells that contain a question mark, and "*~~*" counts cells that contain a tilde.

How to combine wildcards with a cell reference#

Join the wildcard to a cell with &, so you can change the search word without editing the formula. If H1 holds the word Mouse:

Excel formula
=SUMIF(B2:B9,"*"&H1&"*",D2:D9)

This adds the stock of every product containing Mouse: 47 + 12 = 59. Type Cable in H1 and the result changes to 389. Keep the * inside quotes and H1 outside them. Writing "*H1*" would look for the letters H1.

Wildcards with COUNTIFS and SUMIFS#

Wildcards work in any criteria pair of COUNTIFS and SUMIFS. To count charger SKUs in the Leeds warehouse:

Excel formula
=COUNTIFS(A2:A9,"CHG-*",C2:C9,"Leeds")

The result is 2 (CHG-201 and CHG-203). For more on combining conditions, see COUNTIFS and SUMIFS with multiple criteria. If you want the basics of each function first, read how to use COUNTIF and how to use SUMIF.

Wildcards in AVERAGEIF, MAXIFS and MINIFS#

The other conditional functions read wildcards in exactly the same way. The average stock of the cable SKUs:

Excel formula
=AVERAGEIF(A2:A9,"CAB-*",D2:D9)

That's 389 ÷ 3 = 129.67. And the largest stock among chargers, in Excel 2019 or newer:

Excel formula
=MAXIFS(D2:D9,B2:B9,"*Charger*")

The result is 132 (the Wall Charger). One common slip: a space inside the pattern counts as a character. "* Cable*" needs a space before Cable, so it would miss a product that starts with the word Cable.

When don't wildcards work?#

Wildcards only match text, and only in functions built to read them. Watch for these cases:

  • Real numbers. A number like 101 is not text, so "1*" won't match it. Product codes typed as numbers need to be text for wildcards to work.
  • Dates. Dates are numbers too, so "2025*" won't find dates in 2025. Use a date range instead: sum by date range or month with SUMIFS.
  • Comparisons. =A2="CAB*" checks for the exact text CAB*, so it returns FALSE for CAB-101. In IF, use ISNUMBER(SEARCH("CAB",A2)) to test for contains.
  • FIND. FIND treats * and ? as normal characters. SEARCH supports wildcards.

Lookups can use wildcards too: VLOOKUP and MATCH with an exact match, and XLOOKUP with match_mode 2. See wildcard matches with XLOOKUP.

For syntax references, see the COUNTIF guide and the SUMIF guide.

Practise it#

Practise wildcards and cell-based criteria in a live spreadsheet. You'll count SKUs that start with CAB-, total stock for products containing a word, use ? for one character, and build criteria like ">"&H5 and "*"&H8&"*".

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Add up the stock of every product whose name contains Cable. Click G2 and use SUMIF with a wildcard: check B2:B9 and add D2:D9.

fx
ABCDEFGH
1
SKU
Product
Warehouse
Stock
2
CAB-101
USB-C Cable 1m
Leeds
240
Cable stock
3
CAB-102
USB-C Cable 2m
Bristol
85
4
CHG-201
Wall Charger 20W
Leeds
132
5
CHG-202
Car Charger
Bristol
18
6
CAB-103
HDMI Cable 2m
Leeds
64
7
MSE-301
Wireless Mouse
Bristol
47
8
MSE-302
Gaming Mouse
Leeds
12
9
CHG-203
Wireless Charger
Leeds
55
10
11
12

Tip: "Contains" means an asterisk on both sides of the word, all inside one pair of quotes.

Practise this in a lesson

LessonWildcards and cell-based criteriaMatch partial text with * and ?, and build criteria from cells like ">"&H5 so your formulas adapt.Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and a live exercise.Function guideSUMIFAdd up values that meet one condition with SUMIF. Totals by category, person or amount, the argument-order trap, and a live exercise.

Frequently asked questions

What are the wildcard characters in Excel?

+

There are three: * matches any number of characters, ? matches exactly one character, and ~ escapes the next character so that * or ? is matched literally.

How do I count cells that contain a word?

+

Put an asterisk on both sides of the word: =COUNTIF(B2:B9,"Cable"). It counts every cell with Cable anywhere in the text, in any capitals.

How do I use a wildcard with a cell reference?

+

Join the wildcard to the cell with &: =SUMIF(B2:B9,""&H1&"",D2:D9). Keep the * in quotes and the cell outside them.

Why doesn't my wildcard match numbers?

+

Wildcards only match text. A real number like 101 isn't matched by "1*". If you need to match the digits, the cells must hold text, or use a helper column with TEXT.

Which Excel functions support wildcards?

+

COUNTIF, COUNTIFS, SUMIF, SUMIFS, AVERAGEIF, AVERAGEIFS, MAXIFS, MINIFS, SEARCH, MATCH and VLOOKUP with an exact match, and XLOOKUP with match_mode 2. FIND and the = operator don't.

Sources

  • COUNTIF function - Microsoft Support
  • SUMIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published October 30, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. What are the wildcard characters in Excel?
  2. How to use the * wildcard: starts with, ends with, contains
  3. How to use the ? wildcard for one character
  4. How to match a real * or ? with the tilde (~)
  5. How to combine wildcards with a cell reference
  6. Wildcards with COUNTIFS and SUMIFS
  7. When don't wildcards work?
  8. Practise it

Keep reading

Conditional math· 7 min read

Sum by Date Range or Month in Excel With SUMIFS

To sum between two dates, give SUMIFS the same date column twice: once with ">="&start and once with "<"&end. For January 2025, write =SUMIFS(D2:D9,A2:A9,">="&DATE(2025,1,1),A2:A9,"<"&DATE(2025,2,1)). Keep the operator in quotes and join the date with &. Using "before the 1st of next month" works for every month.

Conditional math· 6 min read

How to Use COUNTIF in Excel (With Criteria Examples)

COUNTIF counts the cells in a range that meet one condition. Write =COUNTIF(range, criteria), for example =COUNTIF(D2:D9,"Open") to count open tickets. Put text and comparisons in double quotes, like ">=8" or "<>Low". Numbers and cell references go in without quotes. For two or more conditions, use COUNTIFS.

Conditional math· 7 min read

How to Use SUMIF in Excel

SUMIF adds up the numbers in the rows that meet one condition. Write =SUMIF(range, criteria, sum_range): the cells to check, what they must match, then the numbers to add. For example, =SUMIF(C2:C9,"Travel",D2:D9) totals all Travel claims. Leave out sum_range when the condition is about the numbers themselves.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback. The first lessons are free, with no download.

Start learning for free