0Pricing
Excel Formulas Academy · Lesson

Using Wildcards in Criteria

Match partial text with asterisk and question mark wildcards.

Using Wildcards in Criteria is a free Excel Formulas Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Excel Formulas Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

When Exact Matches Are Not Enough

So far your criteria matched a value exactly. But real data is messy. You might want every product code that starts with AB, or every job title that contains the word Manager.

Wildcards let you match partial text inside SUMIF, COUNTIF, and AVERAGEIF. Two special characters do all the work: the asterisk and the question mark.

Meet the Two Wildcards

There are exactly two:

  • * the asterisk matches any number of characters, including none
  • ? the question mark matches exactly one character

You place them inside the quoted criteria text. Everything you have learned about quotes and the ampersand still applies.

Starts-With Matching

Put the asterisk at the end to mean any ending. To count every code in A2:A10 that starts with AB, follow AB with an asterisk.

This matches AB, AB1, ABXYZ, anything beginning with those two letters. The asterisk stands in for whatever comes after.

=COUNTIF(A2:A10, "AB*")

Ends-With Matching

Put the asterisk at the start to match any beginning. To total amounts in B2:B10 where the label in column A ends with the word North, lead with an asterisk.

This catches Far North, Up North, and plain North. The asterisk absorbs whatever sits before the word.

=SUMIF(A2:A10, "*North", B2:B10)

Contains Matching

Wrap the text in asterisks on both sides to match anywhere inside the cell. To count titles in A2:A10 that contain Manager:

This finds Sales Manager, Manager of IT, and Assistant Manager alike. The two asterisks allow any text before and after the word you care about.

=COUNTIF(A2:A10, "*Manager*")

The Question Mark for Single Characters

The question mark matches exactly one character, no more, no less. If codes are always a letter followed by two digits, count those starting with A using one question mark per unknown character.

"A??" matches A12 and A99 but not A1 or A123, because the length must be exactly three.

=COUNTIF(A2:A10, "A??")

Wildcards Plus a Cell Reference

To build a starts-with condition from a cell, join the cell to an asterisk with the ampersand. If D1 holds AB, match anything beginning with that text.

The & attaches the asterisk to the value in D1, producing "AB*". Now your partial match is driven by a cell instead of hardcoded text.

=COUNTIF(A2:A10, D1&"*")

Contains, Driven by a Cell

The same trick builds a contains search. Surround the cell with asterisks on both sides using two ampersands.

Here the value in D1 is wrapped as "*value*", so changing D1 instantly changes what the formula searches for. This is the heart of a simple search-as-you-type summary.

=SUMIF(A2:A10, "*"&D1&"*", B2:B10)

Matching a Literal Star or Question Mark

What if your data actually contains a real * or ? and you want to match it literally? Put a tilde ~ in front of it.

So "~?" finds a literal question mark, and "~*" finds a literal asterisk. The tilde tells the spreadsheet to treat the next character as ordinary text.

=COUNTIF(A2:A10, "*~?*")

Wildcards Are Text Only

One important limit: wildcards work on text, not numbers. You cannot use * to match part of a number like a price.

If your codes are stored as real numbers, wildcards will not see them. Convert them to text first, or use comparison operators for numeric ranges instead. Wildcards and number operators solve different problems.

=COUNTIF(A2:A10, "INV*")

A Deeper Example: Department Rollup

Imagine codes like SALES-01, SALES-02, HR-01 in column A and budgets in column B. To total the whole Sales department, match any code that starts with SALES followed by anything.

One SUMIF with "SALES*" rolls up every sub-code at once, no need to list them individually. Swap the prefix to roll up a different department.

=SUMIF(A2:A10, "SALES*", B2:B10)

Quick Check

Test your understanding of wildcard matching.

Recap: Wildcards in Criteria

You can now match partial text in the IF math functions. Remember:

  • * matches any number of characters; ? matches exactly one.
  • Use "AB*" for starts-with, "*North" for ends-with, and "*Manager*" for contains.
  • Join a cell with the ampersand, as in D1&"*".
  • Escape a literal * or ? with a tilde, and remember wildcards only work on text.

That completes conditional math with SUMIF, COUNTIF, and AVERAGEIF.

=SUMIF(A2:A10, "*North", B2:B10)

Frequently asked questions

Is the “Using Wildcards in Criteria” lesson free?

Yes — the full text of “Using Wildcards in Criteria” is free to read here on the web, and the Excel Formulas Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Excel Formulas Academy course, upgrade to CoddyKit PRO.

What will I learn in “Using Wildcards in Criteria”?

Match partial text with asterisk and question mark wildcards. You practise Excel Formulas Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Excel Formulas Academy?

No prior experience is required. Excel Formulas Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Using Wildcards in Criteria” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Excel Formulas Academy lesson?

Yes. Every Excel Formulas Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Summing by Criteria With SUMIF
  2. Counting by Criteria With COUNTIF
  3. Averaging by Criteria With AVERAGEIF
  4. Using Wildcards in Criteria
← Back to Excel Formulas Academy