Excel Substring Match: How to Find Text Within a Cell
In this article
To perform a substring match in Excel, use the SEARCH function or the FIND function wrapped inside an ISNUMBER function. For example, the formula =ISNUMBER(SEARCH("text", A1)) will return TRUE if the specific text is found anywhere within cell A1 and FALSE if it is not. This approach allows you to identify specific keywords, partial strings, or patterns within larger bodies of text without requiring an exact match of the entire cell content.
Substring matching is essential for data cleaning, categorizing large lists of transactions, or filtering spreadsheets based on partial names or product codes. Unlike a standard equal sign (=) which requires the cell to be identical to your search term, substring methods look inside the string. Depending on whether you need the search to be case-sensitive or if you want to use wildcards, you will choose between different function combinations.
What You'll Need
- Microsoft Excel (any version from 2010 onwards, including Office 365).
- A dataset containing the text strings you wish to analyze.
- A basic understanding of how to enter formulas into a cell.
Step-by-Step
- Prepare Your Data: Ensure your data is organized in columns. For this guide, assume your target text is in Column A (starting at A2) and you want the result of the match to appear in Column B.
- Choose Your Matching Method: Decide if case sensitivity matters. If you want to find "Apple" but not "apple", use the
FINDfunction. If you want to find both regardless of capitalization, use theSEARCHfunction. - Enter the Basic Search Formula: In cell B2, type
=SEARCH("keyword", A2). Replace "keyword" with the actual text you are looking for. When you press Enter, Excel will return a number representing the starting position of the substring. If the text is not found, Excel will return a#VALUE!error. - Convert the Result to a Boolean (TRUE/FALSE): Because a number or an error is not ideal for filtering, wrap the formula in
ISNUMBER. Change the formula to:=ISNUMBER(SEARCH("keyword", A2)). Now, if the substring exists, the cell will display TRUE; otherwise, it will display FALSE. - Use a Cell Reference for Flexibility: Instead of typing the keyword directly into the formula, type your search term into a separate cell (e.g., cell D1). Update your formula to
=ISNUMBER(SEARCH($D$1, A2)). The dollar signs (absolute references) ensure that as you drag the formula down, it always looks at cell D1 for the keyword. - Apply Conditional Logic with IF: To make the result more readable (e.g., "Found" vs "Not Found"), wrap the formula in an IF statement:
=IF(ISNUMBER(SEARCH($D$1, A2)), "Match", "No Match"). - Drag the Formula Down: Click the small green square (fill handle) at the bottom-right corner of cell B2 and drag it down to the end of your dataset to apply the substring match to all rows.
- Filter the Results: Select your header row, go to the Data tab, and click Filter. You can now click the dropdown arrow in Column B to show only the rows that returned a "Match".
Common Mistakes
One of the most frequent errors is forgetting that SEARCH and FIND return the position of the text, not a yes/no answer. Users often try to use =IF(SEARCH("text", A1), "Yes", "No"). This fails because if the text is not found, the #VALUE! error breaks the entire IF statement. You must always use ISNUMBER to translate that position into a TRUE/FALSE value before the IF statement can process it.
Another common mistake is ignoring the difference between SEARCH and FIND. SEARCH is case-insensitive and supports wildcards (like * for any number of characters or ? for a single character). FIND is case-sensitive and does not support wildcards. Using FIND when you actually need a case-insensitive search will lead to missed matches and inaccurate data analysis.
Lastly, users often forget to use absolute references (the $ signs) when referencing a search term in a separate cell. If you use =ISNUMBER(SEARCH(D1, A2)) and drag it down, the next cell will look at D2, then D3, and so on. If your keyword is only in D1, all subsequent rows will return FALSE regardless of the data in Column A.
Tips
To match multiple different substrings at once, you can use an array constant within the SEARCH function. For example, =OR(ISNUMBER(SEARCH({"Red", "Blue", "Green"}, A2))). This formula will return TRUE if any of those three colors are found within the cell. Note that in older versions of Excel, you may need to press Ctrl+Shift+Enter to activate this as an array formula.
If you need to match a substring only at the beginning of a cell, you can bypass the SEARCH function and use the LEFT function. For example, =LEFT(A2, 5)="Apple" checks if the first five characters of the cell are exactly "Apple". Similarly, the RIGHT function can be used to match substrings at the end of a string.
For highly complex substring matching—such as finding a pattern like "three digits followed by a dash"—standard formulas become cumbersome. In these cases, consider using Power Query (found under the Data tab > Get Data). Power Query has a "Text.Contains" feature in its formula language (M) that is often faster and more intuitive for cleaning massive datasets than cell-based formulas.
Troubleshooting
If your formula is returning #VALUE!, it is likely because you are using SEARCH or FIND without wrapping them in ISNUMBER. These functions are designed to tell you where the text is; if it isn't there, they report an error. Ensure your formula structure is =ISNUMBER(SEARCH(...)).
If the formula returns FALSE even though you can clearly see the text in the cell, check for hidden characters. Leading or trailing spaces are the most common culprits. Use the TRIM function to clean your data. You can wrap your target cell in the formula like this: =ISNUMBER(SEARCH($D$1, TRIM(A2))). This removes extra spaces from the start and end of the text before the search is performed.
If you are using wildcards (like *) and they aren't working, ensure you are using the SEARCH function. The FIND function treats the asterisk as a literal character rather than a wildcard. If you are trying to find a literal asterisk in your text using SEARCH, you must put a tilde (~) before it (e.g., "~*") to tell Excel not to treat it as a wildcard.
If the formula is not updating when you change the keyword in your reference cell, check your Calculation Options. Go to the Formulas tab > Calculation Options and ensure it is set to Automatic. If it is set to Manual, you will need to press F9 to refresh the results.
Frequently Asked Questions
Can I use substring matching with VLOOKUP?
Yes, you can use wildcards within a VLOOKUP. For example, =VLOOKUP("*keyword*", A2:B10, 2, FALSE) will find the first cell in the range that contains the keyword anywhere in the text and return the corresponding value from the second column.
What is the difference between SEARCH and FIND?
SEARCH is case-insensitive (it ignores whether letters are uppercase or lowercase) and allows the use of wildcards. FIND is case-sensitive (it distinguishes between "A" and "a") and does not support wildcards.
How do I count how many cells contain a specific substring?
Use the COUNTIF function with wildcards. The formula =COUNTIF(A2:A100, "*keyword*") will count every cell in the range that contains the specified text, regardless of what else is in the cell.
Can I match a substring based on a partial number?
SEARCH and FIND only work on text. If your data consists of numbers, you must first convert them to text. You can do this by wrapping the cell reference in the TEXT function: =ISNUMBER(SEARCH("123", TEXT(A2, "0"))).
Is there a way to find a substring and then extract the text following it?
Yes, you can combine MID, SEARCH, and LEN. For example, to get everything after the word "ID:", you would use =MID(A2, SEARCH("ID:", A2) + 3, LEN(A2)), where 3 is the length of the search term "ID:".