Home » Excel: How to Use IF Function with Text Values

Excel: How to Use IF Function with Text Values

by Tutor Aspire

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

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 Excel:

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:

Excel IF function check if cell is equal to text

The formula returns “Yes” for the one row where the value in column A is equal to “Starting Center” and returns “No” for all other rows.

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:

Excel IF function 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:

Excel IF function check if cell contains one of several 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 Excel:

Excel: How to Use IF Function with Multiple Conditions
Excel: How to Create IF Function to Return Yes or No
Excel: How to Use an IF Function with Range of Values

You may also like