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

The IF function in Google Sheets is a powerful tool that allows users to perform logical tests and return different results based on the outcome of the test. This function can also be used with text values, allowing users to compare strings of text and return specific results. To use the IF function with text values, the user must first specify the text values to be compared and then specify the desired outcome for each result. This can be useful for various applications, such as categorizing data or creating conditional statements. By understanding how to use the IF function with text values, users can enhance their data analysis and organization in Google Sheets.

Google Sheets: Use IF Function with Text Values


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.

Additional Resources

The following tutorials explain how to perform other common tasks in Google Sheets:

x