How to Use Partial Matching in Excel
In this article
Partial matching in Excel allows you to find data based on a fragment of text rather than an exact string. This is essential when dealing with inconsistent naming conventions, such as finding "Smith" within "John Smith Jr." or identifying product codes that share a common prefix. You can achieve this using wildcards in lookup functions like VLOOKUP and XLOOKUP, or by employing the SEARCH function for more flexible conditional logic.
What You'll Need
- Microsoft Excel (desktop or web version)
- A dataset containing text strings where partial matches are required
- Basic understanding of cell references and formulas
Step-by-Step
- Identify your search criteria: Determine the specific text fragment you want to match against. For example, if you are looking for any entry containing "North", your search term is "North".
- Choose your method: Decide whether you need to return a value from another column (using VLOOKUP/XLOOKUP) or simply check if a match exists (using SEARCH/COUNTIF).
- Apply wildcards for lookup functions: If using VLOOKUP or XLOOKUP, wrap your search term in asterisks. The syntax is
*text*. For instance, to find a row where the name contains "Smith", use"*Smith*"as the lookup value. - Construct the formula: Enter the formula into the result cell. For a VLOOKUP example assuming names are in column A and IDs in column B, type:
=VLOOKUP("*Smith*", A:B, 2, FALSE). Ensure the last argument is FALSE (or 0) to enforce approximate matching via wildcards rather than exact binary search. - Use SEARCH for conditional checks: If you just need to know if a substring exists, use the SEARCH function. Type
=ISNUMBER(SEARCH("North", A1)). This returns TRUE if "North" is found anywhere in cell A1, regardless of case. - Handle dynamic inputs: To make the formula reusable, reference a cell containing the search term instead of hardcoding it. Combine the ampersand operator with wildcards:
=VLOOKUP("*"&D1&"*", A:B, 2, FALSE), where D1 contains the text "Smith". - Verify results: Check that the returned values correspond to the intended partial matches. Be aware that standard lookup functions return only the first match found.
Common Mistakes
One frequent error is forgetting to set the range lookup argument to FALSE (or 0) in VLOOKUP. Without this, Excel assumes sorted data and may return incorrect results or errors when using wildcards. Another common mistake is confusing case sensitivity. While SEARCH is not case-sensitive, FIND is. Using FIND for partial matching will fail if the capitalization does not match exactly. Additionally, users often neglect to escape special characters. If your search term includes an asterisk (*) or question mark (?) as literal characters, you must precede them with a tilde (~), such as ~*, to prevent Excel from interpreting them as wildcards.
Tips
For modern versions of Excel, prefer XLOOKUP over VLOOKUP. It handles partial matching similarly but offers better performance and flexibility, such as searching from bottom-to-top or returning multiple columns at once. When dealing with large datasets, wildcard lookups can be slower because they require scanning every cell. If performance becomes an issue, consider using helper columns with standardized keys or filtering data before applying formulas. Always test your formulas with edge cases, such as empty cells or entries that contain only spaces, to ensure robustness.
Troubleshooting
If your partial match returns #N/A, first verify that the text actually exists in the source range. Check for hidden leading or trailing spaces, which can prevent matches; use the TRIM function to clean data if necessary. Ensure that the data types match; sometimes numbers stored as text will not match numeric lookups even with wildcards. If the formula works for some items but not others, inspect the problematic cells for special characters that might need escaping. Finally, confirm that you are using the correct sheet references and that the range specified in the formula covers all relevant rows.
Frequently Asked Questions
Can I do partial matching without wildcards?
Yes, you can use the LEFT, RIGHT, or MID functions combined with IF statements to check specific positions of text, though this is less flexible than wildcards for general substring searches.
Does partial matching work with numbers?
Wildcards generally do not work directly on numeric values. You must convert numbers to text using the TEXT function or store them as text format before applying wildcard-based partial matching.
How do I find all partial matches?
Standard lookup functions return only the first match. To find all instances, use FILTER (in newer Excel versions) or array formulas with INDEX and SMALL, or utilize Power Query for robust extraction.
Is partial matching case-sensitive?
No, when using wildcards with VLOOKUP or XLOOKUP, or when using the SEARCH function, the matching is case-insensitive. Use the FIND function if you require case-sensitive partial matching.