6.2 C
London
Thursday, December 19, 2024
HomeSoftware TutorialsGoogle SheetsGoogle Sheets: A Simple Formula for “If Contains”

Google Sheets: A Simple Formula for “If Contains”

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

You can use the following formula in Google Sheets to determine if a cell contains a certain string:

=IF(REGEXMATCH(B1, "this"), 1, 0)

In this example, if cell B1 contains the string “this” then it will return a 1, otherwise it will return a 0.

The following examples show how to use this formula in practice.

Related: Google Sheets: A Simple Formula for “If Not Empty”

Example 1: Use “If Contains” For One String

The following formula shows how to create a new column that returns a 1 if the team name is equal to Lakers and a 0 if the team name is not equal to Lakers:

Note that you can also return string values such as “Yes” or “No” instead of numeric values:

Example 2: Use “If Contains” For One of Several Strings

The following formula shows how to create a new column that returns a 1 if the team name is equal to Lakers or Mavericks and a 0 if the team name is something else:


You can find more Google Sheets tutorials on this page.

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories