Catalog

How to Use IF CONTAINS Function to Check Text in Google Sheets (With Examples)

January 30, 2024 2.0K views

Ever felt a bit lost in the Google Sheets maze? Don't worry, we've been there too. This guide is like having a friendly guide on your journey. Picture this: turning Google Sheets from a puzzle into a toolkit for your data. No tech jargon, just easy steps to make your sheets work for you. Let’s make Google Sheets your data buddy!

Part 1: What Is the IF and REGEXMATCH Function in Google Sheets?

IF Function:

Usefulness: The IF function in Google Sheets is used for conditional logic. It allows you to perform different actions based on whether a specified condition is true or false. This function is valuable for creating dynamic and responsive spreadsheets.

Syntax:

=IF(logical_expression, value_if_true, value_if_false)

  • logical_expression: This is the condition you want to evaluate. If it's true, the function returns value_if_true; otherwise, it returns value_if_false.

  • value_if_true: The value or expression to be returned if the logical expression is true.

  • value_if_false: The value or expression to be returned if the logical expression is false.

Here's a simple example:

=IF(A1>10, "Greater than 10", "Less than or equal to 10")

In this case, if the value in cell A1 is greater than 10, it returns "Greater than 10"; otherwise, it returns "Less than or equal to 10."

REGEXMATCH Function:

Usefulness: The REGEXMATCH function is used for pattern matching using regular expressions in Google Sheets. It checks whether a specified text string matches a given pattern, providing a powerful way to search and manipulate text.

Syntax:

=REGEXMATCH(text, regular_expression)

  • text: The text string you want to check for a match.

  • regular_expression: The regular expression pattern to match against the text.

Here's an example:

=REGEXMATCH(A1, "^[0-9]{3}-[0-9]{2}$")

This formula checks if the text in cell A1 matches the pattern of a social security number like "123-45". The ^[0-9]{3}-[0-9]{2}$ is a regular expression specifying three digits, a hyphen, and then two more digits.

In summary, IF is used for conditional logic, while REGEXMATCH is used for pattern matching with regular expressions in Google Sheets. Both functions are powerful tools for creating dynamic and flexible spreadsheets.

Part 2: Easy Steps to Use IF + REGEXMATCH Function to Check Specific Text in Google Sheets?

Example 1: Checking for "Matric" Certificate

Step 1: Identify the target string and the search location.

  • Target string: "Matric"

  • Search location: Graduation column, with the function placed in a column labeled Message.

identify target

Step 2: Formulate the function

For Row 2: =IF(REGEXMATCH(E2, "Matr"), "Congratulations", "None")

Step 3: Check the output.

Review the Message column; it displays "Congratulations" for Matric certificate holders and "None" for others. Note the case sensitivity, where "matric" in Row 4 is not detected.

Result

Example 2: Checking for "Pencil" or "Pen" in Sales Data

Step 1: Create a new column for the formula.

new column

Step 2: Formulate the IF formula.

Type the IF formula in the selected cell, using the autofill feature for accuracy.

input formula

Step 3: Add the REGEXMATCH formula.

Integrate the REGEXMATCH formula after the open bracket in the IF formula, specifying the cell address for text evaluation (e.g., B2).

Step 4: Include keywords for matches.

Add the keywords for matches after the comma, such as "Pencil | Pen," and complete this segment with a closing bracket.

include keyword

Step 5: Write values for true and false arguments.

Add a comma, put the value for the true argument in quotation marks, add another comma, and do the same for the false argument (e.g., Yes and No).

Write values for true and false arguments.

Step 6: Add a closing bracket and press Enter.

Step 7: Apply the formula to the whole column.

Click on the formula cell, drag it down using the dot in the bottom-right corner to apply it to all cells in the column. The formula will yield "Yes" for cells containing "Pencil" or "Pen" and "No" otherwise.

Result

Part 3: How to Use the IF and SEARCH Function to Check Specific Text in Google Sheets?

Example 1

Step 1: Identify the target string and where to search.

Target string: "Matric"

Search location: Graduation column, with the function placed in a column labeled Message.

identify target

Step 2: Use the function

  • For Row 2: =IFERROR(IF(SEARCH("Matr", E2), "Congratulations"), "None")

Step 3: Review the output.

Examine the Message column; it displays "Congratulations" for Matric certificate holders and "None" for others. The SEARCH function is case-insensitive, capturing both "matric" and "Matric."

Result

Example 2

Step 1: Click on the cell where you want the formula and start typing the IF formula syntax.

typing formula

Step 2: After the open bracket, use SEARCH. Enter the term to search for in quotation marks, add a comma, and reference the cell.

enter search

  • Note: Close the brackets of the SEARCH formula to avoid errors.

Step 3: After closing the SEARCH formula bracket, add a comma and specify the value if the formula returns true. Add another comma and write the value for false, both within quotation marks.

Step 4: Press Enter to execute the formula. Drag down the cell’s border to apply the formula to other cells in the column.

Result

Note: You might get a #VALUE error instead of the "No" response. The FALSE value in the IF formula is redundant, so it can be omitted if preferred.

Part 4: Best Free Alternative to Google Sheets - WPS Spreadsheet

WPS Office

WPS Spreadsheet emerges as a compelling alternative to Google Sheets, boasting full compatibility with major office suites like Microsoft Excel, LibreOffice Calc, and OpenOffice Calc. Its versatility extends to common file formats such as .xls, .xlsx, .xlsm, .xlt, and .csv, allowing seamless editing across various devices and platforms.

Advantages of WPS Spreadsheet:

  • Lightweight Design: Engineered for efficiency, WPS Spreadsheet ensures smooth performance even on less powerful devices.

  • Online Document Support: Facilitates seamless collaboration and real-time updates with support for working on online documents.

  • Safety and Stability: Prioritizes the security and stability of user data, creating a secure environment for all spreadsheet activities.

  • Versatility: Compatible with Microsoft Excel, Google Sheets, LibreOffice Calc, and OpenOffice Calc, ensuring a user-friendly transition for individuals accustomed to these platforms.

  • File Format Agility: Supports a wide array of file formats (.xls, .xlsx, .xlsm, .xlt, and .csv), accommodating diverse document handling needs.

In essence, WPS Spreadsheet stands out as a versatile, user-friendly, and free alternative to Google Sheets, offering compatibility, file format support, and a range of features tailored to diverse user needs.

How to Download WPS Office

Step 1: Visit the WPS Office Website

WPS Office Website

Step 2: Download WPS Office

Click on the prominently displayed "Free Download" button on the website to start the download of the WPS Office setup file.

Click

Step 3: Install WPS Office

After the download is complete, launch the downloaded setup file. Follow the on-screen instructions to seamlessly install WPS Office on your device.

Install

Trustpilotstars4.8
WPS Office- Free All-in-One Office Suite
  • Use Word, Excel, and PPT for FREE, No Ads.

  • Edit PDF files with the powerful PDF toolkit.

  • Microsoft-like interface. Easy to learn. 100% Compatibility.

  • Boost your productivity with WPS's abundant free Word, Excel, PPT, and CV templates.

5,820,008 User
avator
Algirdas Jasaitis
logo

FAQS:

Is it possible to nest multiple IF functions for complex conditions?

Certainly! Nesting IF functions provides you with the flexibility to craft intricate conditional logic that caters to your unique requirements. By nesting these functions, you can create layers of conditions, enabling your formula to respond precisely to various scenarios.

Can I use these functions on the Google Sheets mobile app?

Yes, both IF CONTAINS and related functions are available on the Google Sheets mobile app, making it convenient to manage your data on the go.

Summary

In this comprehensive guide, we've demystified Google Sheets' IF CONTAINS function. Armed with newfound knowledge of IF, REGEXMATCH, and SEARCH functions, you're equipped to tackle diverse text-checking scenarios.

Don't forget to explore the WPS Spreadsheet alternative, a lightweight, secure, and versatile solution for all your document needs. Elevate your data game now!


15 years of office industry experience, tech lover and copywriter. Follow me for product reviews, comparisons, and recommendations for new apps and software.