Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets: If Cell Contains Text Formula

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Use =IF(ISNUMBER(SEARCH("text",A1)),"Yes","No") to check whether a cell contains a piece of text. SEARCH returns a number when the text is found and an error when it is not, ISNUMBER turns that into TRUE or FALSE, and IF converts it into whatever labels you want. That single pattern covers most “contains text” needs in Google Sheets, and you can swap the labels for values, calculations or references to other cells. The steps below build it up from a simple check to case-sensitive, multi-condition and wildcard versions.

What You'll Need

  • A Google account with access to Google Sheets (the formulas work in the browser version and the mobile apps).
  • A sheet with at least one column of text to test, and an empty column beside it for the formula.
  • Basic familiarity with cell references such as A1 and ranges such as A2:A100.

Step-by-Step

  1. Open your sheet and pick a result cell. Click the cell where the answer should appear, for example B2 next to the text in A2. Keeping the formula in the same row makes it easy to fill down later.
  2. Type the basic contains formula. Enter =IF(ISNUMBER(SEARCH("apple",A2)),"Yes","No") and press Enter. If A2 contains “apple”, “pineapple” or “Apple pie”, the cell shows Yes; otherwise it shows No. SEARCH is not case-sensitive, so “APPLE” also matches.
  3. Replace the search text with a cell reference if you want it configurable. Put the word you are looking for in a cell, say D1, and use =IF(ISNUMBER(SEARCH(D1,A2)),"Yes","No"). Changing D1 now changes every result without editing the formula.
  4. Return a value instead of a label. Swap the “Yes” and “No” for numbers, blank text or references. For example =IF(ISNUMBER(SEARCH("paid",A2)),"Paid","") leaves the cell empty when there is no match, which keeps reports tidy.
  5. Fill the formula down the column. Select the cell with the formula, grab the small square handle at its bottom-right corner, and drag down, or double-click the handle to fill to the end of the adjacent data. Relative references adjust automatically, so A2 becomes A3, A4 and so on.
  6. Make it case-sensitive when it matters. Replace SEARCH with FIND: =IF(ISNUMBER(FIND("Apple",A2)),"Yes","No"). FIND treats “apple” and “Apple” as different, which is useful for codes, IDs and product names where capitalisation is meaningful.
  7. Check for one of several words. Nest the checks or use REGEXMATCH. A simple OR version is =IF(OR(ISNUMBER(SEARCH("apple",A2)),ISNUMBER(SEARCH("pear",A2))),"Fruit","Other"). A shorter equivalent is =IF(REGEXMATCH(A2,"apple|pear"),"Fruit","Other"), where the pipe character means “or”.
  8. Use wildcards with COUNTIF when you only need a count. =COUNTIF(A2:A100,"*apple*") counts cells containing “apple” anywhere in the text. The asterisks stand for any characters before and after. Use SUMIF the same way if you need to add numbers from another column for matching rows.
  9. Test the edge cases before relying on it. Try a cell that is empty, one with only spaces, one with the search word in a different case, and one where the word appears as part of a longer word. Adjust the formula until each behaves the way you expect.

Common Mistakes

  • Using =IF(A2="apple",...) for “contains”. The equals sign tests for an exact match, so “pineapple” fails. Use SEARCH or FIND with ISNUMBER for partial matches.
  • Forgetting ISNUMBER. SEARCH returns a number or an error, not TRUE or FALSE. Wrapping it in ISNUMBER is what makes the IF work; ISERROR is the inverse pattern if you prefer to test for “not found”.
  • Expecting SEARCH to be case-sensitive. It is not. Use FIND when case matters, and remember that FIND also treats some characters differently.
  • Mixing up wildcards and regex. COUNTIF and SUMIF use * wildcards; REGEXMATCH uses regular expressions where * means something else. Do not paste a regex pattern into COUNTIF.
  • Leaving the search term unquoted. Text inside a formula must be in double quotes, as in "apple". Without quotes, Sheets looks for a named range and returns an error.
  • Dragging a formula without checking references. If part of the formula should stay fixed, such as the search term in D1, write $D$1 so it does not shift as you fill down.

Tips

  • Use TRIM and LOWER around the cell when data is messy: =IF(ISNUMBER(SEARCH("apple",LOWER(TRIM(A2)))),"Yes","No") removes stray spaces and ignores case.
  • Combine the check with FILTER to pull matching rows into a separate view: =FILTER(A2:C100,ISNUMBER(SEARCH("apple",A2:A100))).
  • For a whole-column summary, use =COUNTIF(A:A,"*apple*") but be aware that whole-column references slow large sheets down; prefer a bounded range such as A2:A5000.
  • Name your search term cell (Data > Named ranges) so formulas read like SEARCH(SearchTerm,A2) and are easier to audit later.
  • Keep a small test block of known values beside your formula while building it, then delete the block once the results look right.

Troubleshooting

  • The formula shows #VALUE! or #NAME?. Check that the search text is in double quotes and that function names are spelled correctly. A missing quote is the usual cause.
  • Everything returns “No” even though the text is there. Look for leading or trailing spaces, non-breaking spaces pasted from websites, or hidden characters. Wrap the cell in TRIM and test again.
  • Results are correct in the first row but wrong after filling down. Inspect the references: a missing $ on the search-term cell causes it to move. Press Ctrl+Z (Cmd+Z on Mac) and fix the reference.
  • COUNTIF finds nothing with a wildcard. Confirm the range is correct and that the cell does not contain an apostrophe at the start, which turns the entry into text that may not match as expected. Also check whether the sheet locale uses a different argument separator, such as a semicolon.
  • The formula is very slow on a large sheet. Replace whole-column references with bounded ranges, and prefer COUNTIF over array formulas that scan the same range repeatedly.
  • You need the position of the text, not just a yes or no. Use SEARCH on its own; it returns the character position of the first match, which you can feed into LEFT, MID or RIGHT to extract parts of the string.

Frequently Asked Questions

How do I check if a cell contains any text at all?

Use =IF(ISTEXT(A2),"Text","Not text"). For “not empty”, use =IF(A2<>"","Filled","Empty").

Can I search for text in more than one column?

Yes. Combine the checks with OR, for example =IF(OR(ISNUMBER(SEARCH("apple",A2)),ISNUMBER(SEARCH("apple",B2))),"Yes","No"), or use REGEXMATCH(A2&" "&B2,"apple") to test the joined text.

Why does SEARCH find “cat” inside “category”?

Because it matches any substring. To match whole words only, use a regular expression with word boundaries, such as REGEXMATCH(A2,"\\bcat\\b"), which will not match “category”.

Is there a way to highlight cells that contain text instead of adding a column?

Yes. Select the range, open Format > Conditional formatting, choose “Text contains” and enter your word. This changes the cell’s appearance without adding a helper column.

Does this work in the Google Sheets mobile app?

The formulas work the same way. Typing long formulas on a phone is awkward, so build them on a computer where possible and they will display correctly in the app.

What is the difference between SEARCH and FIND?

SEARCH ignores case and allows wildcards; FIND is case-sensitive and treats wildcard characters literally. Use FIND for codes and IDs, SEARCH for everyday text matching.