Intro
Learn how to use Google Sheets If Cell Contains Text formula with syntax and examples, including REGEX, IF, and ISNUMBER functions for text search and manipulation.
The power of Google Sheets lies in its ability to manipulate and analyze data efficiently. One of the most useful functions in Google Sheets is the ability to check if a cell contains specific text. This can be achieved through various methods, including using formulas like REGEXMATCH
, SEARCH
, MATCH
, and IF
statements. Let's dive into how you can use these functions to check if a cell contains text in Google Sheets.
When working with data in Google Sheets, it's common to need to identify cells that contain specific words or phrases. This might be for filtering data, applying conditional formatting, or performing calculations based on the presence of certain text. The functions mentioned above are versatile and can be adapted to a wide range of scenarios.
Using the SEARCH
Function
The SEARCH
function is one of the simplest ways to check if a cell contains specific text. The syntax for the SEARCH
function is SEARCH(search_for, text_to_search, [start_at])
, where search_for
is the text you're looking for, text_to_search
is the cell or text you want to search in, and [start_at]
is optional, specifying the character number to start searching from.
Here's an example of how to use the SEARCH
function to check if cell A1 contains the word "example":
=SEARCH("example", A1)
If the word "example" is found in cell A1, the SEARCH
function returns the position of the first character of the word "example" within the text. If "example" is not found, the function returns a #VALUE!
error. To handle this, you might use the IFERROR
function to return a more user-friendly message or value.
Using the REGEXMATCH
Function
The REGEXMATCH
function is more powerful and flexible than SEARCH
. It uses regular expressions to match patterns within text. The syntax is REGEXMATCH(text, pattern)
, where text
is the cell or text you want to search, and pattern
is the regular expression pattern you're looking for.
To check if cell A1 contains the word "example" using REGEXMATCH
, you would use:
=REGEXMATCH(A1, "example")
This function returns TRUE
if the word "example" is found in cell A1 and FALSE
otherwise. The REGEXMATCH
function is case-sensitive, so if you want a case-insensitive search, you can modify the formula like this:
=REGEXMATCH(LOWER(A1), "example")
Or, you can use the (?i)
flag at the start of your pattern to make the search case-insensitive:
=REGEXMATCH(A1, "(?i)example")
Using the IF
Statement
Often, you'll want to perform an action or return a specific value based on whether a cell contains certain text. This is where the IF
statement comes in handy. The basic syntax of an IF
statement is IF(logical_expression, value_if_true, value_if_false)
.
Combining the SEARCH
function with an IF
statement, you could write a formula like this to check if cell A1 contains the word "example" and return "Contains example" if true, or "Does not contain example" if false:
=IF(ISNUMBER(SEARCH("example", A1)), "Contains example", "Does not contain example")
Similarly, using REGEXMATCH
with an IF
statement:
=IF(REGEXMATCH(A1, "(?i)example"), "Contains example", "Does not contain example")
Practical Applications
- Conditional Formatting: You can use these functions to apply conditional formatting to cells based on their content. For example, highlighting cells in column A that contain the word "urgent".
- Filtering Data: Use the
FILTER
function in combination withREGEXMATCH
orSEARCH
to filter a range of data based on whether cells contain specific text. - Data Analysis: In data analysis, identifying patterns or specific text within cells can be crucial. These functions enable you to categorize, summarize, or visualize data based on the presence of certain text.
Gallery of Google Sheets Functions










Gallery of Google Sheets Images
Google Sheets Image Gallery










FAQs
How do I check if a cell contains specific text in Google Sheets?
+You can use functions like `SEARCH`, `REGEXMATCH`, or combine them with `IF` statements to check if a cell contains specific text in Google Sheets.
What is the difference between `SEARCH` and `REGEXMATCH` in Google Sheets?
+`SEARCH` is used for simple text searches and returns the position of the text if found. `REGEXMATCH` uses regular expressions and returns `TRUE` or `FALSE` based on whether the pattern is matched.
How can I make my text search case-insensitive in Google Sheets?
+You can make your search case-insensitive by using the `LOWER` function to convert both the search term and the cell text to lowercase, or by using the `(?i)` flag in `REGEXMATCH`.
In conclusion, checking if a cell contains specific text in Google Sheets is a versatile and powerful feature that can be achieved through several functions and methods. Whether you're using SEARCH
, REGEXMATCH
, or combining these with IF
statements, Google Sheets provides the tools you need to efficiently analyze and manipulate your data based on text content. By mastering these techniques, you can unlock more advanced data analysis capabilities and streamline your workflow in Google Sheets. Feel free to share your experiences or ask further questions in the comments below, and don't forget to share this article with anyone who might benefit from learning more about the capabilities of Google Sheets.