Locating specific records within messy, unstructured spreadsheets is a notorious frustration for data analysts. Before resorting to complex VBA scripts or external databases-the traditional "funding sources" of enterprise data solutions-it is vital to explore Excel's native capabilities. Mastering wildcard lookups grants you the immediate ability to extract precise insights from partial text strings without tedious manual data cleaning. However, the key stipulation is that exact wildcard positioning (using * or ?) is required to prevent false matches. For example, matching "*Corp*" can seamlessly map "Microsoft Corp" to its financial records. Below, we outline the exact formula syntax, step-by-step implementation, and optimization techniques for flawless partial matching.
Excel is an incredibly powerful tool for data analysis, but raw data is rarely perfect. Often, you need to perform lookups where you don't have an exact match. You might have partial text, inconsistent formatting, or descriptions containing key search phrases. In these situations, a standard, exact-match VLOOKUP or INDEX/MATCH will fail, returning frustrating #N/A errors.
To solve this, you can leverage wildcard criteria. By combining Excel's INDEX and MATCH functions with wildcard characters, you can build flexible, dynamic search engines within your spreadsheets. This comprehensive guide will walk you through how wildcards work in Excel, how to construct index formulas for partial matches, and how to handle advanced scenarios like reverse wildcard lookups and modern XLOOKUP alternatives.
Before diving into the formulas, it is essential to understand the three wildcard characters that Excel recognizes:
*): Represents any sequence of characters (including zero characters). For example, "App*" can match "Apple", "Appliance", or just "App".?): Represents any single character. For example, "Te?t" can match "Test", "Text", or "Tent".~): Acts as an escape character. If you need to search for an actual asterisk or question mark in your data, you place a tilde before it (e.g., "~*" or "~?").By integrating these symbols into your lookup keys, you tell Excel to find matches based on patterns rather than identical strings.
The most common scenario is having a partial search term (like a keyword) and wanting to find a record in a table that contains that term. Let's look at a practical example.
Imagine we have the following inventory table containing product codes and prices:
| Row | Product Code (Col A) | Product Name (Col B) | Price (Col C) |
|---|---|---|---|
| 2 | APP-102-RED | Fuji Apples | $3.50 |
| 3 | BAN-903-YEL | Organic Bananas | $1.99 |
| 4 | ORA-504-ORG | Valencia Oranges | $4.20 |
| 5 | CHY-301-RED | Bing Cherries | $5.50 |
If you want to find the price of "Bananas" by searching only for the partial string "BAN", you can use wildcards inside your MATCH function.
Enter your partial search term in cell E2 (e.g., "BAN"). In cell F2, write the following formula:
=INDEX(C2:C5, MATCH("*" & E2 & "*", A2:A5, 0))
"*" & E2 & "*"): This joins an asterisk to both ends of the value in cell E2. If E2 contains "BAN", the lookup value becomes "*BAN*". This means Excel will look for any cell in the target range that contains the sequence "BAN" anywhere within it.MATCH(..., A2:A5, 0)): The third argument of MATCH is set to 0 (exact match mode). However, when 0 is selected, Excel natively supports wildcard patterns. It searches through range A2:A5 and identifies that "BAN-903-YEL" in row 3 matches the pattern "*BAN*". It returns the relative row index, which is 2 (the second item in the list).INDEX(C2:C5, 2)): INDEX looks at the price range C2:C5 and retrieves the value at row index 2, which returns $1.99.What if your lookup value is a full description, but your reference table contains only short keyword patterns? For instance, you have transaction descriptions like "7-ELEVEN STORE 1234 NEW YORK" and you want to look it up against a category mapping table that contains just the keyword "7-ELEVEN".
In this case, a standard wildcard MATCH won't work because the wildcards are inside the cells of your reference range, not your search key. To solve this, we must use an array formula utilizing SEARCH and ISNUMBER.
| Keyword (Col A) | Category (Col B) |
|---|---|
| 7-Eleven | Convenience Store |
| Shell | Gas Station |
| Netflix | Subscriptions |
If your transaction description in cell D2 is "SHELL OIL 9876 HOUSTON TX", you want to retrieve the category "Gas Station".
In Excel 365, Excel 2021, or higher, write this formula in cell E2:
=INDEX(B2:B4, MATCH(TRUE, ISNUMBER(SEARCH(A2:A4, D2)), 0))
Note: If you are using Excel 2019 or older, you must press Ctrl + Shift + Enter instead of just Enter to run this as an array formula.
SEARCH(A2:A4, D2): This searches for each of our keywords ("7-Eleven", "Shell", "Netflix") inside the target string "SHELL OIL 9876...". It evaluates as an array. Since "7-Eleven" is not found, it returns a #VALUE! error. "Shell" is found, so it returns its starting position (position 1). "Netflix" returns #VALUE!. The resulting array is {#VALUE!; 1; #VALUE!}.ISNUMBER(...): This converts the array into boolean values. Numbers become TRUE and errors become FALSE. The array becomes {FALSE; TRUE; FALSE}.MATCH(TRUE, ..., 0): The MATCH function looks for the value TRUE within our boolean array. It finds it at position 2.INDEX(B2:B4, 2): Finally, INDEX looks at the categories (B2:B4) and extracts the item at position 2, which is "Gas Station".If you are using Microsoft 365 or Excel 2021, the new XLOOKUP function streamlines wildcard matches significantly, removing the need to nest INDEX and MATCH.
By default, XLOOKUP searches for exact matches. However, it features a built-in parameter to enable wildcard matching.
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode])
To use wildcards, you set the match_mode argument (the 5th argument) to 2.
Using the fruit inventory table from Scenario 1, if you want to find the price of "ORA" (Valencia Oranges) using wildcards in XLOOKUP:
=XLOOKUP("*" & E2 & "*", A2:A5, C2:C5, "No Match Found", 2)
This is cleaner, easier to write, and lets you handle missing matches gracefully with the optional "No Match Found" parameter.
While indexing with wildcard criteria is incredibly powerful, there are potential issues you should keep in mind:
Both MATCH and XLOOKUP stop searching once they identify the *first* matching instance. If your wildcard pattern is too broad (such as searching for "*A*"), the formula will return the first item containing the letter 'A', which might not be the correct record. Keep your search terms as specific as possible.
The MATCH and SEARCH functions are case-insensitive. Searching for "*apple*" will match "APPLE", "Apple", and "aPpLe". If you need case-sensitive matching, you must replace SEARCH with the FIND function, which respects capitalization.
If your lookup cell (e.g., cell E2) is blank, the concatenated wildcard term will resolve to "". In Excel, this will match the very first text string in your range. To prevent false matches on blank inputs, wrap your index formulas inside an IF statement:
=IF(E2="", "", INDEX(C2:C5, MATCH("*" & E2 & "*", A2:A5, 0)))
Mastering wildcard searches with INDEX/MATCH and XLOOKUP elevates your data-cleansing and parsing skills in Excel. Whether you are dealing with inconsistent product lists, searching through bank ledger transaction strings, or reconciling legacy databases, wildcards ensure you can retrieve the correct data even when key entries aren't identical. Use the native MATCH wildcard argument for standard lookups, opt for array-based SEARCH formulas for reverse-lookup cases, and leverage XLOOKUP with a match_mode of 2 to stay up to speed with modern Excel features.
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.