Excel Formula Search for Text in Cell: Best Methods
In this article
To search for text in an Excel cell, the most effective method is using the SEARCH function, often wrapped in an ISNUMBER function to return a simple "True" or "False" result. For example, =ISNUMBER(SEARCH("text", A1)) will tell you if the specified text exists anywhere within cell A1, regardless of whether it is uppercase or lowercase.
Searching for text is essential for cleaning large datasets, categorizing entries based on keywords, or flagging specific items for review. Whether you need a case-insensitive search or a strict match, Excel provides several built-in functions to handle these tasks without needing to manually scan thousands of rows.
What You'll Need
- A computer with Microsoft Excel installed (works across Windows, macOS, and Excel for the Web).
- A dataset containing the text strings you wish to analyze.
- A basic understanding of how to enter formulas into a cell.
Step-by-Step
- Identify your target cell and keyword: Determine which cell contains the text you want to search (e.g., cell A2) and the specific word or phrase you are looking for (e.g., "Paid").
- Use the SEARCH function for basic detection: If you only need to know the position of the text, enter
=SEARCH("keyword", A2). If the word is found, Excel returns the character number where the text starts. If it is not found, it returns a #VALUE! error. - Convert the result to a True/False value: Because #VALUE! errors are difficult to work with in large sheets, wrap the SEARCH function in ISNUMBER. Enter:
=ISNUMBER(SEARCH("keyword", A2)). This will return TRUE if the text is present and FALSE if it is not. - Create a custom label using the IF function: To make the results more readable (e.g., "Found" instead of "TRUE"), wrap the formula in an IF statement. Enter:
=IF(ISNUMBER(SEARCH("keyword", A2)), "Found", "Not Found"). - Apply the formula to the rest of the column: Click the small green square (fill handle) in the bottom-right corner of the cell containing your formula and drag it down to apply the search to all other rows in your dataset.
- Switch to FIND for case-sensitive searches: If you specifically need to find "Apple" but not "apple", replace the word SEARCH with FIND in your formula:
=ISNUMBER(FIND("Apple", A2)).
Common Mistakes
- Forgetting Quotation Marks: Text strings inside Excel formulas must always be enclosed in double quotation marks (e.g., "Text"). If you omit them, Excel will look for a named range and return a #NAME? error.
- Confusing SEARCH and FIND: Users often use SEARCH when they actually need a case-sensitive match. Remember: SEARCH is case-insensitive; FIND is case-sensitive.
- Searching for Empty Cells: If the cell you are searching is empty, the formula will return FALSE. If the "keyword" you are searching for is an empty cell reference, Excel may return a 1 (TRUE) for every cell, which can lead to incorrect data analysis.
- Hard-coding Keywords: Typing the keyword directly into every formula makes it hard to change later. Instead, type the keyword in a single cell (e.g., D1) and reference that cell in your formula:
=ISNUMBER(SEARCH($D$1, A2)).
Tips
- Use Wildcards: The SEARCH function supports wildcards. Use a question mark (?) to match any single character or an asterisk (*) to match any sequence of characters.
- Combine Multiple Keywords: To search for "Text A" OR "Text B", use the OR function:
=OR(ISNUMBER(SEARCH("Text A", A2)), ISNUMBER(SEARCH("Text B", A2))). - Conditional Formatting: Instead of a new column, use the
=ISNUMBER(SEARCH("keyword", A2))formula within Conditional Formatting to automatically highlight cells that contain the specific text. - Dynamic Search: By referencing a cell for your keyword, you can change the word in that one cell and watch your entire list of "Found/Not Found" labels update instantly.
Troubleshooting
The formula returns #VALUE!
This happens when you use the SEARCH or FIND function alone and the text is not found. To fix this, wrap the function in ISNUMBER() or IFERROR() to handle the missing value gracefully.
The formula is not finding text that I can clearly see
Check for hidden characters. Often, data imported from the web contains "non-breaking spaces" or trailing spaces that make a match fail. Try using the =TRIM(A2) function to remove extra spaces before searching.
The formula returns TRUE for every single row
Check if your search term reference is pointing to an empty cell. If you use =SEARCH(D1, A2) and cell D1 is blank, Excel considers that a match for every cell. Ensure your keyword cell has a value.
The case-sensitivity is not working
Ensure you are using the FIND function. If you are using SEARCH, it will ignore whether the text is uppercase or lowercase. If FIND is still not working, check if your data has inconsistent capitalization (e.g., "aPPle" vs "Apple").
Frequently Asked Questions
Can I search for text across multiple cells at once?
Standard SEARCH and FIND functions only work on a single cell. To search across a range, you can use the COUNTIF function: =COUNTIF(A1:A10, "*keyword*"). If the result is greater than 0, the text exists in that range.
How do I search for text and then extract it?
To extract text, you can combine MID, SEARCH, and LEN. For example, to extract everything after a specific word, you use SEARCH to find the starting point and MID to pull the remaining characters.
Does the SEARCH function work with numbers?
Yes, but it treats the number as text. If you search for "123" in a cell containing "Order 12345", it will return a match. If you need to find an exact numerical match, it is better to use a standard equals sign (=A1=123).
Is there a way to search for text and return a value from another column?
Yes, you can use XLOOKUP or VLOOKUP with wildcards. For example, =XLOOKUP("*keyword*", A1:A10, B1:B10, "Not Found", 2) will search for a partial match in column A and return the corresponding value from column B.
What is the difference between SEARCH and FIND?
The only functional difference is case sensitivity. SEARCH ignores capitalization (A=a), while FIND requires an exact match of uppercase and lowercase letters.