Excel Formula If Cell Contains: A Quick Guide
In this article
Yes, Excel can check whether a cell contains a specific word or piece of text and return a result based on it. The most reliable modern formula is =IF(ISNUMBER(SEARCH("text", A1)), "Yes", "No"), which checks cell A1 for the word inside the quotation marks. If your version of Excel supports it, the newer CONTAINS function may not be available, so this guide sticks to functions that work everywhere: SEARCH, FIND, COUNTIF and IF. Everything below works in Excel for Microsoft 365, Excel 2019/2021 and Excel for the web; menu labels can differ slightly by version and platform.
What You'll Need
- A spreadsheet with at least one column of text values to check
- Excel (desktop, web or mobile); the formulas are identical in all of them
- Basic familiarity with typing formulas into a cell
Step-by-Step
- Open your spreadsheet and identify the cell you want to test (for example, A2) and the cell where you want the result (for example, B2).
- Click the result cell (B2) and type the basic contains-check formula:
=IF(ISNUMBER(SEARCH("apple", A2)), "Yes", "No"). Press Enter. SEARCH returns a number when the text is found and an error when it is not, so ISNUMBER converts that into TRUE or FALSE for IF. - Replace "apple" with your own word, keeping the quotation marks, and change A2 to whichever cell you are testing.
- Understand the case behaviour: SEARCH is case-insensitive (it treats "apple" and "APPLE" the same). If you need an exact, case-sensitive match, use FIND instead:
=IF(ISNUMBER(FIND("Apple", A2)), "Yes", "No"). - Fill the formula down by selecting B2 and double-clicking the small square (the fill handle) at the bottom-right corner of the cell, or by dragging it down alongside your data.
- For a simpler exact-match count across a range, use COUNTIF:
=IF(COUNTIF(A2:A100, "*apple*")>0, "Found", "Not found"). The asterisks are wildcards meaning "any text before or after". - To check for multiple words at once, combine checks with OR:
=IF(OR(ISNUMBER(SEARCH("apple",A2)), ISNUMBER(SEARCH("pear",A2))), "Match", "No match"). - To return part of the found text or the row itself rather than Yes/No, wrap the check in an IF that outputs A2:
=IF(ISNUMBER(SEARCH("apple",A2)), A2, ""). - Format the results column if desired: select it, then use Home > Conditional Formatting > Highlight Cells Rules > Text that Contains to colour matching cells visually.
Common Mistakes
- Forgetting the quotation marks around the search text. =SEARCH(apple, A2) fails because Excel treats apple as a (probably empty) named reference.
- Using ISNUMBER on the whole IF instead of on SEARCH only. The structure must be IF(ISNUMBER(SEARCH(...)), result_if_found, result_if_not).
- Expecting SEARCH to be case-sensitive. It is not; use FIND for case sensitivity.
- Confusing SEARCH's argument order. It is SEARCH(what_to_find, where_to_look). Reversing them gives wrong answers or errors.
- Trailing spaces in the data. A cell containing "apple " still matches, but a lookup for the exact cell may not; use TRIM on messy data.
- Not locking ranges with $ signs (for example $A$2:$A$100) when copying a COUNTIF formula across, causing the range to shift unexpectedly.
Tips
- Put the search word in its own cell (for example D1) and reference it:
=IF(ISNUMBER(SEARCH($D$1, A2)), "Yes", "No"). You can then change the search term once instead of editing every formula. - SEARCH and FIND also accept a third argument, start_number, if you want to begin looking from a specific character position.
- Wildcards in COUNTIF:
*matches any number of characters,?matches exactly one character, and~*searches for a literal asterisk. - If you have Microsoft 365, FILTER can list all rows containing a word:
=FILTER(A2:A100, ISNUMBER(SEARCH("apple", A2:A100)))in a single cell. - Numbers stored as text will still be matched by SEARCH, but be aware that numeric formatting can affect what COUNTIF matches.
Troubleshooting
- The formula returns #NAME? – you likely misspelled a function name or omitted quotation marks. Check spelling of IF, ISNUMBER, SEARCH.
- The formula returns #VALUE! – the cell you are testing is empty or contains an error value. Wrap the check:
=IF(AND(A2<>"", ISNUMBER(SEARCH("apple",A2))), "Yes", "No"). - Everything returns "No" even though matches exist – check for leading/trailing spaces with TRIM, confirm the search text spelling, and make sure you referenced the right cell (absolute versus relative references).
- The formula shows as plain text in the cell – the cell was probably formatted as Text before you typed. Change it to General (Home > Number Format dropdown), then re-enter the formula.
- Locale issues – in some regional settings Excel uses semicolons instead of commas between arguments:
=IF(ISNUMBER(SEARCH("apple";A2);"Yes";"No"). Use whichever separator your version accepts. - COUNTIF wildcard not matching – confirm your data does not contain a literal asterisk or tilde, and remember COUNTIF is case-insensitive.
Frequently Asked Questions
What is the basic Excel formula for "if cell contains"?
=IF(ISNUMBER(SEARCH("word", A2)), "Yes", "No"). Replace "word" and A2 with your search term and target cell.
Is there a built-in CONTAINS function in Excel?
No. Excel has no dedicated CONTAINS function; the standard approach is combining IF with SEARCH or FIND, or using COUNTIF with wildcards.
How do I make the check case-sensitive?
Use FIND instead of SEARCH: =IF(ISNUMBER(FIND("Word", A2)), "Yes", "No"). FIND distinguishes upper and lower case; SEARCH does not.
How do I check if a cell contains a number?
Use =IF(ISNUMBER(A2), "Number", "Not a number") to test whether the entire cell is numeric. To find a number inside text, SEARCH works the same way: =ISNUMBER(SEARCH(42, A2)).
How do I check if a cell contains one of several words?
Combine checks with OR, or use SUMPRODUCT with COUNTIF against a list of words in a helper range.
Can I do this in Google Sheets too?
Yes. SEARCH, FIND, ISNUMBER, IF and COUNTIF with wildcards all work identically in Google Sheets.