Conditional Formatting: Text Match in Another Cell

Ever found yourself in a situation where you need to format a cell's content based on whether it contains specific text from another cell? Microsoft Excel's Conditional Formatting feature makes this possible with its "Contains Text" rule. Let's delve into how you can leverage this powerful tool to add conditional formatting that checks if a cell contains text from another cell.

Excel Conditional Formatting Based on Another Cell Tutorial
Excel Conditional Formatting Based on Another Cell Tutorial

Before we dive into the steps, let's understand why you might need this. Suppose you have a large dataset where you want to highlight cells that contain certain keywords from a separate list. Or perhaps you want to format cells based on whether they match any text in a specific cell. This guide will walk you through the process, ensuring you master this useful Excel skill.

How to Copy Conditional Formatting to Another Cell in Excel
How to Copy Conditional Formatting to Another Cell in Excel

Setting Up Your Workbook

To begin, ensure your workbook is set up with the necessary data. For this example, let's assume you have two columns: 'A' containing keywords and 'B' containing text you want to check against these keywords.

Excel Conditional Formatting If a Cell Contains Any Text
Excel Conditional Formatting If a Cell Contains Any Text

Here's a simple layout:

Column AColumn B
Keyword1This is some text containing Keyword1
Keyword2This text does not contain Keyword2
Keyword3This text contains Keyword3 and other words
How to conditional formatting if the cell contains partial text in Excel?
How to conditional formatting if the cell contains partial text in Excel?

Using the "Contains Text" Rule

Now, let's apply conditional formatting to Column B, checking if it contains text from Column A.

1. Select cells in Column B (B2:B4 in our case).

Google Sheets - Conditional Formatting Based on Another Cell
Google Sheets - Conditional Formatting Based on Another Cell

2. Click on 'Home' > 'Conditional Formatting' > 'New Rule'.

3. In the 'New Formatting Rule' dialog box, select 'Use a formula to determine which cells to format'.

4. In the 'Format values where this formula is true:' box, enter the following formula: `=COUNTIF($A$2:$A$4, "*"&B2&"*")>0`

How to Do Conditional Formatting Based on Another Cell in Excel (6 Easy Ways) - ExcelDemy
How to Do Conditional Formatting Based on Another Cell in Excel (6 Easy Ways) - ExcelDemy

5. Choose the formatting you want to apply (e.g., fill color) and click 'OK'.

Understanding the Formula

Conditional formatting in Excel: Learn with Examples
Conditional formatting in Excel: Learn with Examples
Excel Conditional Formatting
Excel Conditional Formatting
Apply Conditional Formatting on Multiple Texts in Excel
Apply Conditional Formatting on Multiple Texts in Excel
Excel Conditional Formatting tutorial with examples
Excel Conditional Formatting tutorial with examples
an excel spreadsheet with multiple columns and numbers
an excel spreadsheet with multiple columns and numbers
Conditional Formatting on Text that Contains Multiple Words in Excel
Conditional Formatting on Text that Contains Multiple Words in Excel
Excel Conditional Formatting with Formula If Cell Contains Text
Excel Conditional Formatting with Formula If Cell Contains Text
Conditional Formatting in Excel
Conditional Formatting in Excel
Conditional Formatting in Excel (Complete Guide + Examples)
Conditional Formatting in Excel (Complete Guide + Examples)
Change Cell Colour using Conditional Formatting
Change Cell Colour using Conditional Formatting
the basic excel formats for each type of text, including numbers and letters that are in
the basic excel formats for each type of text, including numbers and letters that are in
Custom Formatting Follow Josh Aharonoff, CPA for more content. This is my favorite Excel trick 😎 No…not to be confused with conditional formatting  Custom Formatting is even cooler…allowing you… | Excel for CFOs
Custom Formatting Follow Josh Aharonoff, CPA for more content. This is my favorite Excel trick 😎 No…not to be confused with conditional formatting Custom Formatting is even cooler…allowing you… | Excel for CFOs
Conditionally format a cell which has part of its text match any value from a range of cells in a specific column
Conditionally format a cell which has part of its text match any value from a range of cells in a specific column
An Intro to Using Conditional Formatting in Excel
An Intro to Using Conditional Formatting in Excel
Conditional Format Borders in Excel‼️ #excel
Conditional Format Borders in Excel‼️ #excel
Format Cells in Excel Based on the Condition or Content
Format Cells in Excel Based on the Condition or Content
5 Handy Excel Tricks for Conditional Formatting Every Analyst Should Know
5 Handy Excel Tricks for Conditional Formatting Every Analyst Should Know
How to Apply Conditional Formatting in Excel - Highlight Data Visually
How to Apply Conditional Formatting in Excel - Highlight Data Visually
How to Use Conditional Formatting in Excel
How to Use Conditional Formatting in Excel
Excel Conditional Formatting Tutorial
Excel Conditional Formatting Tutorial

The formula used here is `=COUNTIF($A$2:$A$4, "*"&B2&"*")>0`. Let's break it down:

  • `$A$2:$A$4` refers to the range containing your keywords.
  • `*&B2&*` wraps the content of the active cell (B2) with asterisks, making the COUNTIF function consider partial matches.
  • `>0` checks if the count is greater than zero, i.e., if the cell contains any of the keywords.

This formula ensures that Excel formats cells in Column B that contain text from Column A.

Applying Conditional Formatting to Multiple Cells

If you want to apply this formatting to a larger range or multiple cells simultaneously, you can adjust the formula accordingly.

For example, if you want to apply the same formatting to cells in Column C that contain text from Column A, you can use the formula `=COUNTIF($A$2:$A$4, "*"&C2&"*")>0`.

Formatting Based on Multiple Conditions

You can also combine this rule with others to create more complex conditional formatting. For instance, you might want to format cells based on whether they contain specific text and also meet other criteria, such as being greater than a certain value.

To do this, you can use the AND function in your formula. For example, to format cells that contain text from Column A and are greater than 100, use the formula `=AND(COUNTIF($A$2:$A$4, "*"&B2&"*")>0, B2>100)`.

Mastering conditional formatting in Excel opens up a world of possibilities for data analysis and presentation. By understanding how to apply the "Contains Text" rule, you can create dynamic and engaging spreadsheets that help you make sense of your data.

Remember, practice makes perfect. Don't hesitate to experiment with different formulas and rules to find what works best for your specific needs. Happy formatting!