Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Use Excel Wildcards: Asterisk, Question Mark, and Tilde

Use Excel wildcard patterns in searches, filters, and formulas, with examples for partial matches, fixed-length text, and literal special characters.

Table of Contents

Excel uses * to match any sequence of characters and ? to match exactly one character in supported text searches. Put ~ before a special character when you want to search for the character itself. These patterns work in tools such as Find, text filters, and functions including COUNTIF and SEARCH.

Wildcards are patterns, not regular expressions, and not every Excel function interprets them. Choose the pattern for the tool you are using and check the results on a few known entries.

Wildcard reference

PatternMeaningExample
*Zero or more charactersBed* matches text beginning with Bed in a whole-cell criterion.
?Exactly one characterp??ce matches peace and piece.
~*A literal asteriskFind an actual * character.
~?A literal question markFind an actual ? character.
~~A literal tildeFind an actual ~ character.

Use an asterisk for partial text matches

For a whole-cell text criterion, these patterns have different meanings:

  • Bed*: starts with Bed.
  • *sheet: ends with sheet.
  • *Manager*: contains Manager anywhere.
  • B*t: starts with B and ends with t, with any number of characters between.

Find and filter matching entries

Press Ctrl + F, enter a pattern, and use Find All to inspect the matches. Under Options, check Match entire cell contents when the pattern should describe the complete cell; otherwise Find can match part of a longer value.

For a job-title column, open its filter menu and choose Text Filters > Contains, then enter Manager. The Contains condition already looks within the text. This displays titles such as Regional Manager and Manager II.

Count matching cells

=COUNTIF(B2:B30,"*Manager*")

This counts text entries containing Manager. COUNTIF's text comparison is not case-sensitive. For its range and criteria arguments, see TipsMake's COUNTIF guide.

If B2:B30 contains addresses and C2:C30 contains names, this returns names whose address contains Lagos:

=FILTER(C2:C30,ISNUMBER(SEARCH("Lagos",B2:B30)),"No matches")

SEARCH returns a position when it finds the text; ISNUMBER turns that result into a TRUE/FALSE filter condition. A trailing wildcard is unnecessary for this simple substring search.

To require a space immediately after Lagos, use:

=FILTER(C2:C30,ISNUMBER(SEARCH("Lagos *",B2:B30)),"No matches")

This still searches anywhere in the address. It does not prove that Lagos is the city, require it to appear at the beginning, or uniquely identify one person. Use a separate city field when those distinctions matter.

FILTER requires a version that supports dynamic arrays, such as Microsoft 365, Excel 2021, or Excel 2024. Keep the return and condition ranges aligned and leave space for the spilled results. TipsMake's data lookup and filtering examples cover related tools.

Use question marks for fixed-length text

A question mark matches one character, including a letter, digit stored as text, space, or punctuation. Six question marks can therefore count six-character text identifiers:

=COUNTIF(A2:A6,"??????")

INV002 has six characters; INV-002 has seven. This checks length, not whether an ID follows every business rule. Numeric cells are not matched in the same way as text identifiers, so keep codes as text if this is the intended validation.

Wildcards in Excel are the secret weapon for faster, smarter searching Picture 7

Highlight text codes with the wrong length

Select D2:D6 and create a conditional-formatting rule using a formula:

=COUNTIF(D2,"?????")=0

COUNTIF returns 1 when the cell matches five text characters and 0 when it does not. The comparison =0 makes the rule TRUE for a nonmatching cell, so that cell receives the format. The rule also flags blank cells and numeric entries.

If blanks are permitted, use:

=AND(D2<>"",COUNTIF(D2,"?????")=0)

Keep D2 relative when applying the rule down the selected range. Test a valid five-character text code, a shorter one, and a blank before using the rule on the full dataset.

Use a tilde to find literal special characters

Wildcards in Excel are the secret weapon for faster, smarter searching Picture 8

In Find, enter ~? to locate an actual question mark, or ~* to locate an actual asterisk. Leave whole-cell matching off when you want cells that contain the character within longer text.

For IDs such as P*Laos*45, count entries beginning with the literal text P*Laos* followed by any suffix:

=COUNTIF(A1:A43,"P~*Laos~**")

The two ~* sequences match literal separators. The final unescaped * allows the remaining suffix. Requiring the second literal separator avoids also counting a different label that merely begins with Laos.

Wildcards in Excel are the secret weapon for faster, smarter searching Picture 9

Check unexpected matches before replacing data

Leading spaces, hidden characters, and mismatched text/number types can change results. SEARCH is case-insensitive, and ordinary equality comparisons do not automatically interpret wildcard strings. See the SEARCH function guide for how search positions are returned.

Use Find All or a formula result to review matches before a bulk replacement. Wildcards can select a much wider set of text than a literal search, especially when the pattern includes an asterisk.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.