To find out whether a cell contains a word or phrase anywhere in its text, combine SEARCH, ISNUMBER and IF:
=IF(ISNUMBER(SEARCH("refund", A2)), "Yes", "No")
This returns Yes when the word “refund” appears anywhere in A2, whether at the start, middle or end of the text. SEARCH is not case-sensitive, so “Refund” and “REFUND” also match.
Why ISNUMBER is needed
SEARCH returns the position of the text it finds, as a number. If the text isn’t there, it returns the #VALUE! error instead. ISNUMBER turns that result into TRUE for a number and FALSE for an error, so IF gets a clean test.
Without ISNUMBER, a cell that doesn’t contain the word would show #VALUE! rather than “No”.
SEARCH or FIND
SEARCH and FIND both locate text, but they differ in two ways:
- SEARCH ignores capital letters and accepts wildcards. A question mark stands for one character, and an asterisk stands for any number of characters.
- FIND is case-sensitive and doesn’t accept wildcards.
For example, =IF(ISNUMBER(FIND("ID", A2)), "Yes", "No") matches “ID” but not “id”. When case matters, FIND is the right choice. For most everyday checks, SEARCH is simpler. The two functions are compared in more detail in find vs search in excel.
Exact match versus contains
Use = when the whole cell has to match the text:
=IF(A2="refund", "Yes", "No")
This returns Yes only when A2 contains just “refund”, with capital letters not mattering. A cell that says “Refund request” returns No with this formula, because the test looks at the whole cell. SEARCH looks for the text inside the cell.
Extra spaces matter for exact matches. A trailing space turns “refund “ into a different value from “refund”. See remove extra spaces in excel formula for a fix.
Check for any of several words
To test whether a cell contains one of several words, combine SEARCH tests with OR:
=IF(OR(ISNUMBER(SEARCH("refund", A2)), ISNUMBER(SEARCH("return", A2))), "Yes", "No")
The formula returns Yes if either word appears. It gets long as the list grows, so for more than a few words, a different layout is easier to maintain. For two or three words, the OR version is clear.
Count cells that contain the text
If you need a count instead of a label on each row, COUNTIF accepts wildcards. An asterisk on each side of the word matches any text before and after it:
=COUNTIF(A2:A200, "*refund*")
This counts every cell in A2:A200 that contains “refund” anywhere in its text. COUNTIF isn’t case-sensitive. How to use countif in excel covers its other criteria options.
If you need the matching part of the text rather than a yes or no, see how to extract text from a cell in excel.