How can I use IF function with text values in Google Sheets?


You can use the following formulas to use an IF function with text values in Google Sheets:

Method 1: Check if Cell is Equal to Text

=IF(A2="Starting Center", "Yes", "No")

This formula will return “Yes” if the value in cell A2 is “Starting Center” – otherwise it will return “No.”

Method 2: Check if Cell Contains Specific Text

=IF(ISNUMBER(SEARCH("Guard", A2)), "Yes", "No")

This formula will return “Yes” if the value in cell A2 contains “Guard” anywhere in the cell – otherwise it will return “No.”

Method 3: Check if Cell Contains One of Several Specific Texts

=IF(SUMPRODUCT(--ISNUMBER(SEARCH({"Backup","Guard"},A2)))>0, "Yes", "No")

This formula will return “Yes” if the value in cell A2 contains “Backup” or “Guard” anywhere in the cell – otherwise it will return “No.”

The following examples show how to use each formula in practice with the following dataset in Google Sheets:

Example 1: Check if Cell is Equal to Text

We can type the following formula into cell C2 to return “Yes” if the value in cell A2 is equal to “Starting Center” or return “No” otherwise:

=IF(A2="Starting Center", "Yes", "No")

We can then click and drag this formula down to each remaining cell in column C:

Google Sheets IF function with text

Example 2: Check if Cell Contains Specific Text

We can type the following formula into cell C2 to return “Yes” if the value in cell A2 contains “Guard” anywhere in the cell or return “No” otherwise:

=IF(ISNUMBER(SEARCH("Guard", A2)), "Yes", "No")

We can then click and drag this formula down to each remaining cell in column C:

Google Sheets IF function to check if cell contains text

The formula returns “Yes” for each row that contains “Guard” in column A and returns “No” for all other rows.

Example 3: Check if Cell Contains Several Specific Texts

We can type the following formula into cell C2 to return “Yes” if the value in cell A2 contains “Backup” or “Guard” anywhere in the cell or return “No” otherwise:

=IF(SUMPRODUCT(--ISNUMBER(SEARCH({"Backup","Guard"},A2)))>0, "Yes", "No")

We can then click and drag this formula down to each remaining cell in column C:

Google Sheets IF function with multiple text values

The formula returns “Yes” for each row that contains “Backup” or “Guard” in column A and returns “No” for all other rows.

Note: Feel free to include as many text values as you’d like in the curly brackets in the formula to search for as many specific text values in a cell as you’d like.

x