Excel: If a Cell Contains Specific Text (Formulas That Work)
Learn the formulas for checking if an Excel cell contains specific text: ISNUMBER with SEARCH or FIND, COUNTIF wildcards, several keywords, and REGEXTEST.
To check whether an Excel cell contains specific text, use =IF(ISNUMBER(SEARCH("text",A2)),"Yes","No"). SEARCH finds the text anywhere inside the cell (ignoring case), ISNUMBER turns the result into TRUE or FALSE, and IF returns whatever labels you want.
That one formula covers most situations. The rest of this guide explains why it works, how to make it case-sensitive, how to test several words at once, and when COUNTIF or the newer REGEXTEST function is a better fit.
Why Excel needs a workaround
Excel has no built-in CONTAINS function. Microsoft’s own support article on checking if a cell contains text uses the same three-function combination shown above: IF, SEARCH and ISNUMBER.
Here is what each piece does:
- SEARCH(“text”, A2) returns the position of the first character where “text” starts inside A2. If the text is not there, it returns the
#VALUE!error, as Microsoft explains in its #VALUE! troubleshooting page for FIND and SEARCH. - ISNUMBER(…) converts that into a clean TRUE (a position number came back) or FALSE (an error came back).
- IF(…) lets you return something more useful than TRUE/FALSE, such as “Yes”, a category name, or a calculation.
The basic formula, step by step
Say column A holds product descriptions and you want to flag every row that mentions “wireless”.
- Click cell B2 (next to your first description).
- Type
=IF(ISNUMBER(SEARCH("wireless",A2)),"Wireless","")and press Enter. - Drag the fill handle down to copy the formula to the rest of the column.
Rows containing “wireless”, “Wireless” or “WIRELESS” get the label; others stay blank.
Pointing to a cell instead of typing the word
Hard-coding the word works, but it is easier to maintain if the search term lives in its own cell. If the term is in E1:
=IF(ISNUMBER(SEARCH($E$1,A2)),"Match","No match")
The dollar signs keep the reference fixed on E1 when you copy the formula down. Forum answers on Microsoft’s Tech Community recommend this pattern, especially when you have several keywords to manage.
One caution: if E1 is empty, SEARCH treats the empty string as a match, so every row will report a match. If that can happen in your sheet, add a check such as =IF(AND($E$1<>"",ISNUMBER(SEARCH($E$1,A2))),"Match","No match").
Case-sensitive checks with FIND
SEARCH ignores case. If “Apple” (the company) and “apple” (the fruit) must be treated differently, swap SEARCH for FIND. Microsoft’s case-sensitive version of the article uses exactly this approach:
=IF(ISNUMBER(FIND("Apple",A2)),"Yes","No")
FIND works the same way as SEARCH, returning a position or #VALUE!, with two differences:
- It is case-sensitive, and you can’t switch that off.
- It does not support wildcards. A
*or?inside FIND is treated as a literal character.
SEARCH vs FIND vs COUNTIF vs REGEXTEST
| Approach | Case-sensitive? | Wildcards | Best for |
|---|---|---|---|
ISNUMBER(SEARCH(...)) | No | ? and * | Everyday “does this cell contain X” checks |
ISNUMBER(FIND(...)) | Yes | No | When capitalization matters |
COUNTIF(cell,"*text*")>0 | No | ? and * | Quick checks, and whole ranges |
REGEXTEST(cell,pattern) | Yes by default (configurable) | Regex patterns | Complex patterns, Microsoft 365 only |
COUNTIF with wildcards
COUNTIF is another popular way to test for partial text. The asterisk stands for “any characters”, so wrapping your term in asterisks means “contains”:
=IF(COUNTIF(A2,"*wireless*"),"Yes","No")
COUNTIF returns 1 when the cell matches and 0 when it doesn’t, and IF treats any non-zero number as TRUE. To use a cell reference, join the asterisks on with &: COUNTIF(A2,"*"&$E$1&"*").
COUNTIF really shines on ranges. Exceljet’s range example uses =COUNTIF(rng,"*"&D5&"*")>0 to return TRUE if any cell in a range contains the text in D5. COUNTIF is not case-sensitive, so it can’t replace FIND when case matters.
Searching for a literal * or ?
Because SEARCH and COUNTIF treat * and ? as wildcards, put a tilde in front to match the actual character. For example, SEARCH("~?",A2) looks for a real question mark, per Exceljet’s SEARCH reference.
Checking for several words at once
Any of several words (OR)
Wrap multiple SEARCH tests in OR:
=IF(OR(ISNUMBER(SEARCH("red",A2)),ISNUMBER(SEARCH("blue",A2))),"Yes","No")
For a longer keyword list, put the words in a range (say H2:H10) and use SUMPRODUCT, an approach suggested in a Microsoft Q&A answer:
=IF(SUMPRODUCT(--ISNUMBER(SEARCH($H$2:$H$10,A2)))>0,"Yes","No")
This counts how many keywords appear in A2 and returns “Yes” if at least one does. Adding a keyword is then just a matter of typing it into the list. If the list has blank cells, remember the empty-string caution above: blanks count as matches, so keep the range tight or filter out empties.
All of several words (AND)
Swap OR for AND when every word must be present:
=IF(AND(ISNUMBER(SEARCH("red",A2)),ISNUMBER(SEARCH("large",A2))),"Yes","No")
Returning different labels for different words
Nested IFs work for a few categories:
=IF(ISNUMBER(SEARCH("invoice",A2)),"Billing",IF(ISNUMBER(SEARCH("refund",A2)),"Refunds","Other"))
Forum users on Microsoft’s Tech Community note that deep nesting gets hard to read and edit. Beyond three or four categories, a keyword table with a lookup approach is usually easier to maintain.
The modern option: REGEXTEST
Microsoft added regular expression functions to Excel, including REGEXTEST, which returns TRUE or FALSE depending on whether text matches a pattern. They first appeared as a preview for Microsoft 365 Insiders, as announced on the Microsoft 365 Insider blog.
A simple “contains” check looks like this:
=IF(REGEXTEST(A2,"wireless"),"Yes","No")
REGEXTEST is case-sensitive by default; the REGEXTEST support page documents an optional argument to ignore case. The real benefit is patterns: REGEXTEST(A2,"red|blue|green") checks for any of three words in one short formula.
Availability is the catch. Microsoft’s support page lists Excel for Microsoft 365 on Windows and Mac; some third-party guides also mention Excel for the web, which Microsoft’s page does not confirm. Perpetual versions such as Excel 2016 through 2024 don’t have it, and some users have reported the functions missing on certain builds. As of November 2026, if you share workbooks with people on older Excel versions, stick with ISNUMBER and SEARCH, which work everywhere.
Common problems and fixes
- Formula shows #VALUE!: You used SEARCH or FIND on its own. Wrap it in ISNUMBER.
- Every row says “Yes”: The search-term cell is probably blank, or your keyword range includes empty cells.
- Case-sensitive matches are missed or wrongly found: Check whether you used SEARCH/COUNTIF (case-insensitive) or FIND (case-sensitive).
- COUNTIF returns 0 on numbers: Wildcards only work on text values, so a number stored as a number won’t match
"*5*". SEARCH handles this better because it converts the cell to text. - Partial-word matches: SEARCH(“cat”,A2) also matches “category”. If you need whole words only, add spaces around the term or use a REGEXTEST pattern with word boundaries where it is available.
For most people, the first formula in this guide is all you need: IF(ISNUMBER(SEARCH(...))) for case-insensitive checks, FIND when case matters, and COUNTIF when you are looking across a range.
Free apps worth trying
SponsoredSponsored links. Installing through them can earn us a commission, at no cost to you. Apps are free to download; some offer optional in-app purchases.
Frequently asked questions
Why does my formula return #VALUE! instead of FALSE? +
SEARCH and FIND return the #VALUE! error when the text is not found. Wrap them in ISNUMBER so a match becomes TRUE and a miss becomes FALSE, then put that inside IF to return your own labels.
Is there a CONTAINS function in Excel? +
No. Excel has no dedicated CONTAINS function, which is why the standard approach combines IF, ISNUMBER and SEARCH (or FIND for case-sensitive checks). In current Microsoft 365 builds, REGEXTEST can also test for a pattern.
How do I make the check case-sensitive? +
Use FIND instead of SEARCH. FIND distinguishes uppercase from lowercase, while SEARCH and COUNTIF ignore case. Note that FIND does not accept wildcards.
Can I check a whole column instead of one cell? +
Yes. COUNTIF with wildcards, such as =COUNTIF(A2:A100,"*apple*")>0, returns TRUE if any cell in the range contains the text. Without the >0 it returns how many cells match.
Sources
- Check if a cell contains text (case-insensitive) in Excel - Microsoft Support (support.microsoft.com)
- Check if a cell contains text (case-sensitive) - Microsoft Support (support.microsoft.com)
- How to correct a #VALUE! error in FIND/FINDB and SEARCH/SEARCHB functions - Microsoft Support (support.microsoft.com)
- Range contains specific text - Exceljet (exceljet.net)
- SEARCH function - Exceljet (exceljet.net)
- REGEXTEST Function - Microsoft Support (support.microsoft.com)
- New regular expression (Regex) functions in Excel - Microsoft 365 Insider Blog (techcommunity.microsoft.com)