To check if a field contains text in Excel, use =IF(ISNUMBER(SEARCH("key",A2)),"Yes","No"). SEARCH finds "key" anywhere in A2 and ignores case, ISNUMBER turns the result into TRUE or FALSE, and IF returns your chosen output. To count or total partial matches, use wildcards: =COUNTIF(A:A,"*key*") or =SUMIF(A:A,"*key*",B:B).
| Goal | Formula (text to find in E1, or typed in quotes) |
|---|---|
| Does A2 contain "pro"? | =ISNUMBER(SEARCH("pro",A2)) |
| IF contains, then… | =IF(ISNUMBER(SEARCH("pro",A2)),"Pro edition","") |
| Case-sensitive check | =ISNUMBER(FIND("Pro",A2)) |
| Count cells containing | =COUNTIF(A2:A100,"*pro*") |
| Sum where text contains | =SUMIF(A2:A100,"*pro*",B2:B100) |
| Text held in a cell | =COUNTIF(A2:A100,"*"&E1&"*") |
How do I write "if cell contains text then" in Excel?
Combine IF, ISNUMBER and SEARCH. SEARCH returns the position of the text if it's found, or a #VALUE! error if it isn't. ISNUMBER converts that into TRUE or FALSE, which IF can use.

=IF(ISNUMBER(SEARCH("refund",B2)),"Escalate","OK")
Microsoft's article on how to check if a cell contains text recommends the same IF, SEARCH and ISNUMBER combination and confirms that SEARCH is case-insensitive. If you're new to IF itself, start with our guide to the IF then statement in Excel.
Here's a worked example using order notes:
| Row | A (Product) | B (Note) | C (Formula result) |
|---|---|---|---|
| 2 | Office 2024 Pro Plus | Customer wants refund | Escalate |
| 3 | Windows 11 Pro | Activated fine | OK |
| 4 | Office 2024 Home | REFUND requested | Escalate |
Row 4 matches even though "REFUND" is in capitals, because SEARCH ignores case. If you only want to know whether a cell contains any text at all, rather than particular words, use =ISTEXT(A2).
What we commonly see: people try =IF(A2="*pro*","Yes","No") and it never matches. The equals sign compares exact values and doesn't understand wildcards, so it looks for a literal asterisk-p-r-o-asterisk. Wildcards only work inside functions that accept criteria, such as COUNTIF, SUMIF, XLOOKUP in wildcard mode and MATCH. For an IF test, use ISNUMBER(SEARCH()), or wrap COUNTIF around the single cell: =IF(COUNTIF(A2,"*pro*"),"Yes","No").
How do I check for several words at once?
For "contains any of these words" (OR logic), put the words in an array constant and test them all:
=IF(OR(ISNUMBER(SEARCH({"refund","chargeback","cancel"},B2))),"Escalate","OK")
For "contains all of these words" (AND logic), swap OR for AND. In Excel 2019 and 2016 the OR version works as a normal formula in most cases. If it returns a wrong result, enter it with Ctrl+Shift+Enter. In Excel 2021, 2024 and Microsoft 365, it works as typed.
To keep the list maintainable, put the words in a range such as H2:H4 and use =SUMPRODUCT(--ISNUMBER(SEARCH($H$2:$H$4,B2)))>0. Add a word to the range and every formula picks it up.
How do I use COUNTIF when a cell contains text?
Use asterisks around the text. The asterisk means "any number of characters", so "*pro*" matches anything with "pro" in it. The full set of wildcards is documented on Microsoft's page about wildcard characters.

=COUNTIF(A2:A100,"*pro*") cells containing "pro" anywhere
=COUNTIF(A2:A100,"pro*") cells starting with "pro"
=COUNTIF(A2:A100,"*pro") cells ending with "pro"
=COUNTIF(A2:A100,"*") cells containing any text
=COUNTIF(A2:A100,"<>*pro*") cells NOT containing "pro"
For COUNTIF with partial text taken from a cell, join the wildcards with ampersands: =COUNTIF(A2:A100,"*"&E1&"*"). Change E1 and the count updates. Like SEARCH, COUNTIF ignores case. To count with two conditions, such as "contains Pro" and "region is UK", use COUNTIFS. Our guide to COUNTIFS with multiple criteria covers it, and our COUNT and COUNTA guide explains counting text in general.
How do I use SUMIF with partial text in Excel?
SUMIF accepts the same wildcards. The criteria go in the second argument and the numbers to add in the third:

=SUMIF(A2:A100,"*office*",C2:C100)
=SUMIFS(C2:C100,A2:A100,"*office*",D2:D100,"UK")
The first formula adds up column C wherever column A contains "office". The second adds a second condition with SUMIFS. Note that in SUMIFS the sum range comes first. AVERAGEIF, AVERAGEIFS, MAXIFS and MINIFS accept wildcards the same way.
Advanced nuance: wildcards only work on text. If column A holds numbers such as part codes 10450 and 20450, =COUNTIF(A:A,"*450*") returns 0, because those cells contain numbers, not text. Use =SUMPRODUCT(--ISNUMBER(SEARCH("450",A2:A100))) instead. SEARCH converts each number to text before looking inside it. The same trick handles partial matches where the search text itself contains * or ?, which COUNTIF would treat as wildcards unless you add a tilde.
How do I filter or highlight rows that contain text?
To list matching rows with a formula, use FILTER in Excel 2021, 2024 or Microsoft 365:
=FILTER(A2:D100,ISNUMBER(SEARCH("pro",A2:A100)),"No matches")
To highlight matching cells, select the range and choose Home > Conditional Formatting > Highlight Cells Rules > Text that Contains. To highlight the whole row, use New Rule > Use a formula to determine which cells to format with =ISNUMBER(SEARCH("pro",$A2)). Microsoft 365 also adds REGEXTEST for pattern matching, such as checking whether a cell contains any digits. That function isn't in Excel 2024, as our comparison of Excel 2024 and Excel 365 explains.
What does "This workbook contains links to other data sources" mean?
This message isn't about text in cells. It appears when you open a workbook whose formulas point to another file. Newer versions word it as links to "one or more external sources that could be unsafe". Choose Update to refresh the values from the other file, or Don't Update to keep the last saved values. To find and remove those links so the prompt stops, follow our guide to finding and breaking external links.
Which Excel versions support these formulas?
IF, ISNUMBER, SEARCH, FIND, COUNTIF, SUMIF, COUNTIFS and SUMIFS work in every version from Excel 2016 onwards, on Windows and Mac. MAXIFS and MINIFS need Excel 2019 or later. FILTER and the plain-entry array behaviour need Excel 2021, 2024 or Microsoft 365. REGEX functions are Microsoft 365 only. If you're choosing a version, the Office 2024 collection covers the current perpetual editions.
Frequently asked questions
How do I make the contains check case-sensitive?
Replace SEARCH with FIND, which matches case exactly: =ISNUMBER(FIND("Pro",A2)) is TRUE for "Office Pro" but FALSE for "office pro". COUNTIF and SUMIF are always case-insensitive. For a case-sensitive count, use =SUMPRODUCT(--ISNUMBER(FIND("Pro",A2:A100))), which checks each cell individually.
Why does my COUNTIF contains formula return 0?
The most common reasons are missing asterisks, numbers stored as numbers rather than text, or extra spaces in the criteria. Check that the criteria reads "*text*" with both asterisks inside the quotes. If the range holds numbers, switch to SUMPRODUCT with SEARCH. Also make sure E1 doesn't contain a trailing space if you reference it.
How do I return the matching word instead of Yes?
Use LOOKUP with SEARCH: =LOOKUP(2^15,SEARCH($H$2:$H$4,B2),$H$2:$H$4) returns the keyword from H2:H4 that appears in B2. If none match, it returns #N/A, so wrap it in IFERROR. When several keywords match, it returns the last one in the list.
Can I check if a cell contains a number?
Use =ISNUMBER(A2) if the whole cell should be a number. To test whether text contains any digit, use =SUMPRODUCT(--ISNUMBER(SEARCH({0,1,2,3,4,5,6,7,8,9},A2)))>0. In Microsoft 365, =REGEXTEST(A2,"\d") does the same in a shorter formula.
Does IF contains work with blank cells?
Yes. SEARCH on a blank cell returns an error, so ISNUMBER returns FALSE and the IF returns the "not found" value. If you want blanks to show nothing at all, add a check first: =IF(A2="","",IF(ISNUMBER(SEARCH("pro",A2)),"Yes","No")). Our IF cell is blank guide covers more patterns.
Related guides
- IF cell is blank in Excel
- IFS function in Excel
- Find and replace in Excel with wildcards
- Not equal to in Excel
Links in this guide
| Link | Type | Why it helps |
|---|---|---|
| Microsoft Support: Check if a cell contains text | External | Official IF, SEARCH and ISNUMBER approach |
| Microsoft Support: Wildcard characters | External | The * ? and ~ wildcards for criteria |
| IF then statement in Excel | Internal | IF basics |
| COUNTIFS with multiple criteria | Internal | Combine contains with other conditions |
| COUNT and COUNTA in Excel | Internal | Counting text cells in general |
| Excel 2024 vs Excel 365 | Internal | Which versions have REGEX functions |
| Find and break external links | Internal | Stop the links to other data sources prompt |
| Office 2024 collection | Internal | Current Office editions |
| IF cell is blank | Internal | Handle empty cells |
| IFS function | Internal | Several outcomes from one test |
| Find and replace in Excel | Internal | Wildcard searches without formulas |
| Not equal to in Excel | Internal | Excluding values in criteria |
