Locating specific substrings within massive, unstandardized Excel datasets often frustrates data analysts. Standard exact-match search methods-much like traditional corporate funding sources-limit flexibility and require precise inputs to yield results. However, leveraging wildcards "grants" users a highly adaptable query system, bypassing rigid text constraints to unlock hidden data insights. The key stipulation is mastering how operators like the asterisk (*) and question mark (?) dictate search behaviors. For instance, using SEARCH("xl*", A2) offers concrete proof of how easily partial data can be isolated. Below, we will examine the exact formulas and syntax required to implement wildcard searches efficiently.
In Microsoft Excel, searching for exact matches is straightforward. However, real-world data is rarely perfect. You might find yourself dealing with messy product codes, varied naming conventions, or long strings of text where you only need to locate a specific pattern. This is where substring searches using wildcards become indispensable.
By leveraging Excel's wildcard characters-the asterisk (*), the question mark (?), and the tilde (~)-combined with powerful lookup and text functions, you can build dynamic formulas to find, count, and extract partial text matches. In this comprehensive guide, we will explore the best formulas and techniques to search substrings using wildcards in Excel.
Before diving into the formulas, it is essential to understand the three wildcard characters that Excel recognizes:
| Wildcard | What It Represents | Example Pattern | Matches |
|---|---|---|---|
Asterisk (*) |
Any number of characters (zero or more) | Ex*l |
Excel, Extra-cool, Exol, Exl |
Question Mark (?) |
Exactly one single character | Te?t |
Test, Text, Tent (but not Beast) |
Tilde (~) |
Escapes a wildcard (treats * or ? as literal text) |
What~? |
What? (ignores the wildcard function of ?) |
If you want to check if a cell contains a specific substring using wildcards and return a simple TRUE or FALSE, the combination of SEARCH and ISNUMBER is your best tool.
Excel has two primary substring location functions: SEARCH and FIND.
SEARCH is case-insensitive and supports wildcards.FIND is case-sensitive and does not support wildcards.Therefore, we must always use SEARCH when working with wildcard patterns.
=ISNUMBER(SEARCH(find_text, within_text))
SEARCH function looks for your wildcard pattern within the target cell. If it finds it, it returns the numerical starting position of the match. If it does not find it, it returns a #VALUE! error.ISNUMBER function wraps around the search. If SEARCH returns a number, ISNUMBER yields TRUE. If SEARCH returns an error, it yields FALSE.Imagine you have a list of serial numbers in column A, and you want to flag any item that starts with "AB", ends with "9", and has exactly three characters in between. The pattern you want is AB???9.
=ISNUMBER(SEARCH("AB???9", A2))
If cell A2 contains "AB1049", the formula will return TRUE. If it contains "AB12349" (four characters in between), it will return FALSE because the three question marks strictly require exactly three characters.
Often, you do not just want to know if a substring exists; you want to pull associated data from an adjacent column. You can use wildcards within the lookup value of a VLOOKUP formula to execute partial match lookups.
=VLOOKUP("*" & Lookup_Value & "*", Table_Array, Col_Index_Num, FALSE)
Suppose you have a database of transactions, and you want to look up the price of an item using a shorthand or partial name. Your data table is in range A2:B10, where Column A contains the full product description (e.g., "Premium Wireless Bluetooth Headphones") and Column B contains the price.
If you type "Bluetooth" in cell D2, you can retrieve its price using this wildcard formula:
=VLOOKUP("*" & D2 & "*", A2:B10, 2, FALSE)
By using the concatenation operator (&), Excel builds a lookup string of "*Bluetooth*". The VLOOKUP function searches Column A for any description that contains "Bluetooth" anywhere in the text, and returns the corresponding price from Column B.
Note: Always set the fourth argument of VLOOKUP to FALSE (or 0) to ensure an exact match on your wildcard string pattern.
If you are using Microsoft 365 or Excel 2021, XLOOKUP is a much more robust alternative to VLOOKUP. However, by default, XLOOKUP does not support wildcards unless you explicitly tell it to.
=XLOOKUP(Lookup_Value, Lookup_Array, Return_Array, [If_Not_Found], [Match_Mode])
To enable wildcards, you must set the Match_Mode (the 5th argument) to 2.
Let's perform the same search as our VLOOKUP example, looking up the price of "Bluetooth" using cell D2 as our input:
=XLOOKUP("*" & D2 & "*", A2:A10, B2:B10, "Not Found", 2)
#N/A errors.2, preventing accidental matches when executing standard searches.If your goal is to count how many rows contain a specific substring pattern, COUNTIF and COUNTIFS support wildcard characters natively without needing complex array formulas.
=COUNTIF(Range, Criteria)
1. Count all cells containing the word "Urgent" anywhere in the string:
=COUNTIF(A2:A100, "*Urgent*")
2. Count all email addresses from a specific domain (e.g., ending in "@company.com"):
=COUNTIF(B2:B100, "*@company.com")
3. Count 5-character ID codes that start with "ID-" and end with any single digit/character:
=COUNTIF(C2:C100, "ID-??")
Sometimes, your data actually contains asterisks or question marks that you need to search for. For instance, you might want to find all rows containing the text "Product*".
If you write SEARCH("Product*", A2), Excel will look for "Product" followed by any characters, which is not what you want.
To tell Excel to treat a wildcard character as a standard literal character, prefix it with a tilde (~).
To search for the literal string "Product*", use the following formula:
=ISNUMBER(SEARCH("Product~*", A2))
Likewise, if you are looking for cells that end with a literal question mark, you can use:
=COUNTIF(A2:A100, "*~?")
COUNTIF, VLOOKUP, and SEARCH are case-insensitive. If you require a case-sensitive substring search with complex logical rules, you will need to utilize the FIND function, though you will have to manually construct pattern-matching logic (like checking lengths or character codes) since FIND does not support wildcard operators natively."*" & D2 & "*") and cell D2 is completely empty, the criteria evaluates to "". This matches any text in your range, which might lead to incorrect lookup results or bloated counts. Prevent this by wrapping your formula in an IF statement:
=IF(ISBLANK(D2), "", XLOOKUP("*" & D2 & "*", A2:A10, B2:B10, "No Match", 2))
*value*) force Excel to scan your entire range sequentially rather than utilizing optimized binary search algorithms. On exceptionally large datasets (tens of thousands of rows), extensive wildcard usage can slow down workbook calculation times. Keep your lookup ranges clean and targeted whenever possible.Mastering wildcard formulas in Excel unlocks a brand-new level of data manipulation. Whether you are validating text patterns with SEARCH, pulling critical business numbers using XLOOKUP, or auditing tracking sheets with COUNTIF, wildcards eliminate the friction of working with non-standardized text. Keep this reference handy for the next time you need to dig through messy, unstructured Excel spreadsheets!
Disclaimer:
The documents and templates provided on this page are for informational and illustrative purposes only. They do not constitute professional, legal, or financial advice, and should not be relied upon as such. Because individual circumstances and regulatory requirements vary, these materials may not be suitable for your specific needs. We recommend consulting with a qualified professional before adapting or using any of these examples for official or commercial purposes.