[Solved] How To Use “If Cell Contains” Formulas in Excel

Excel has a number of formulas that help you use your data in useful ways. For example, you can get an output based on whether or not a cell meets certain specifications. Right now, we’ll focus on a function called “if cell contains, then”. Let’s look at an example. If you want to check whether or not the
A1 cell contains the text “Example”, you can run a formula that will output “Yes” or “No” in the B1 cell. There are a number of different ways you can put these formulas to use. At the time of writing, Excel is able to return the following variations:

• If cell contains any value
• If cell contains text
• If cell contains number
• If cell contains specific text
• If cell contains certain text string
• If cell contains one of many text strings
• If cell contains several strings

Using these scenarios, you’re able to check if a cell contains text, value, and more.

Using “if cell contains” formulas in Excel

The guides below were written using the latest Microsoft Excel 2019 for Windows 10. If you’re using a different version or platform, some steps may vary. Contact our experts if you need any further assistance.

1. If cell contains any value, then return a value

This scenario allows you to return values based on whether or not a cell contains any value at all. For example, we’ll be checking whether or not the A1 cell is blank or not, and then return a value depending on the result.

1. Select the output cell, and use the following formula: =IF(cell<>””, value_to_return, “”).
2. For our example, the cell we want to check is A2, and the return value will be No. In this scenario, you’d change the formula to =IF(A2<>””, “No”, “”) 3. Since the A2 cell isn’t blank, the formula will return “No” in the output cell. If the cell you’re checking is blank, the output cell will also remain blank.

2. If cell contains text/number, then return a value

With the formula below, you can return a specific value if the target cell contains any text or number. The formula will ignore the opposite data types.

Check for text

1. To check if a cell contains text, select the output cell, and use the following formula: =IF(ISTEXT(cell), value_to_return, “”).
2. For our example, the cell we want to check is A2, and the return value will be Yes. In this scenario, you’d change the formula to =IF(ISTEXT(A2), “Yes”, “”) 3. Because the A2 cell does contain text and not a number or date, the formula will return “Yes” into the output cell.

Check for a number or date

1. To check if a cell contains a number or date, select the output cell, and use the following formula: =IF(ISNUMBER(cell), value_to_return, “”).
2. For our example, the cell we want to check is D2, and the return value will be Yes. In this scenario, you’d change the formula to =IF(ISNUMBER(D2), “Yes”, “”) 3. Because the D2 cell does contain a number and not text, the formula will return “Yes” into the output cell.

3. If cell contains specific text, then return a value

To find a cell that contains specific text, use the formula below.

1. Select the output cell, and use the following formula: =IF(cell=”text”, value_to_return, “”).
2. For our example, the cell we want to check is A2, the text we’re looking for is “example”, and the return value will be Yes. In this scenario, you’d change the formula to =IF(A2=”example”, “Yes”, “”) 3. Because the A2 cell does consist of the text “example”, the formula will return “Yes” into the output cell.

4. If cell contains specific text, then return a value (case-sensitive)

To find a cell that contains specific text, use the formula below. This version is case-sensitive, meaning that only cells with an exact match will return the specified value.

1. Select the output cell, and use the following formula: =IF(EXACT(cell,”case_sensitive_text”), “value_to_return”, “”).
2. For our example, the cell we want to check is A2, the text we’re looking for is “EXAMPLE”, and the return value will be Yes. In this scenario, you’d change the formula to =IF(EXACT(A2,”EXAMPLE”), “Yes”, “”).
3. Because the A2 cell does consist of the text “EXAMPLE” with the matching case, the formula will return “Yes” into the output cell.

5. If cell does not contain specific text, then return a value

The opposite version of the previous section. If you want to find cells that don’t contain a specific text, use this formula.

1. Select the output cell, and use the following formula: =IF(cell=”text”, “”, “value_to_return”).
2. For our example, the cell we want to check is A2, the text we’re looking for is “example”, and the return value will be No. In this scenario, you’d change the formula to =IF(A2=”example”, “”, “No”). 3. Because the A2 cell does consist of the text “example”, the formula will return a blank cell. On the other hand, other cells return “No” into the output cell.

6. If cell contains one of many text strings, then return a value

This formula should be used if you’re looking to identify cells that contain at least one of many words you’re searching for.

1. Select the output cell, and use the following formula: =IF(OR(ISNUMBER(SEARCH(“string1”, cell)), ISNUMBER(SEARCH(“string2”, cell))), value_to_return, “”).
2. For our example, the cell we want to check is A2. We’re looking for either “tshirt” or “hoodie”, and the return value will be Valid. In this scenario, you’d change the formula to =IF(OR(ISNUMBER(SEARCH(“tshirt”,A2)),ISNUMBER(SEARCH(“hoodie”,A2))),”Valid “,””). 3. Because the A2 cell does contain one of the text values we searched for, the formula will return “Valid” into the output cell.

To extend the formula to more search terms, simply modify it by adding more strings using ISNUMBER(SEARCH(“string”, cell)).

7. If cell contains several of many text strings, then return a value

This formula should be used if you’re looking to identify cells that contain several of the many words you’re searching for. For example, if you’re searching for two terms, the cell needs to contain both of them in order to be validated.

1. Select the output cell, and use the following formula: =IF(AND(ISNUMBER(SEARCH(“string1”,cell)), ISNUMBER(SEARCH(“string2″,cell))), value_to_return,””).
2. For our example, the cell we want to check is A2. We’re looking for “hoodie” and “black”, and the return value will be Valid. In this scenario, you’d change the formula to =IF(AND(ISNUMBER(SEARCH(“hoodie”,A2)),ISNUMBER(SEARCH(“black”,A2))),”Valid “,””). 3. Because the A2 cell does contain both of the text values we searched for, the formula will return “Valid” into the output cell.

Final thoughts

We hope this article was useful to you in learning how to use “if cell contains” formulas in Microsoft Excel. Now, you’re able to check if any cells contain values, text, numbers, and more. This allows you to navigate, manipulate and analyze your data efficiently.

Before you go

If you need any further help with Excel, don’t hesitate to reach out to our customer service team, available 24/7 to assist you. Return to us for more informative articles all related to productivity and modern-day technology!