We’ll use the following simple dataset to showcase how to change row colors based on text values inside cells.
Change the Row Color Based on the Text Value in a Cell in Excel: 3 Suitable Ways
Consider the following dataset with the information for ID, Name, Region, Rank, and Salary of some Sales Representatives. We’ll change some row colors based on the names, regions, or salaries.
Method 1 – Changing the Row Color Based on Text Value
Case 1.1 – For Single Cell Criteria
We have to color the rows that have George’s name in them. We put that value in a separate cell H5.
Steps:
- Select the entire dataset.
- In your Home tab, go to Conditional Formatting in Style Group.
- Click on New Rule.
- The New Formatting Rule dialog box opens. Select Use a Formula to determine which Cells to format to continue.
- In the formula section, insert this formula.
=$C5="George"
- Click on the Format option.
- We have chosen the color of the text as Automatic. Go to the Fill tab and pick a background color. In this case, we chose the Yellow color.
- Click OK.
- Click OK.
- Our row colors are changed based on a text value in a cell.
Case 1.2 – For Multiple Cell Criteria
Consider a case where you have to color the rows that have Asia and rank A in them.
Steps:
- Go to the New Formatting Rule dialog box following the steps of Method 1.1.
- Select Use a formula to determine which cells to format.
- Insert the following formula:
=$D5="Asia"
- Select the color format for your matched cells.
- Click OK.
- The conditional formatting feature successfully colors the rows.
- Go to Conditional Formatting and select Manage Rules.
- The Conditional Formatting Rules Manager window appears. Click New Rule to add another one.
- Set the following formula for the second condition:
=$E5="A"
- Set the format.
- Click OK to change the row color based on multiple conditions.
- Press OK in the next window.
- Here are the results.
Read More: How to Change Cell Color Based on Date Using Excel Formula
Method 2 – Altering Row Color Based on a Number Value in Excel
We have to change the row colors for employees with a salary of less than 40,000$.
Steps:
- Go to New Formatting Rule (see Method 1.1).
- Insert the following formula:
=$F5<$H$5
- Specify the formatting and click OK to continue.
- Here are the results.
Method 3 – Applying a Formula to Change the Row Color Based on a Text Value
Case 3.1 – Using theOR Function
We want to color rows that contain George or Asia. Insert those texts into your reference table.
Steps:
- Insert the following formula in the New Formatting Rule window.
=OR($C5="George",$D5="Asia")
- Select a formatting style according to your preferences.
- Click OK.
Case 3.2 – Inserting AND Function
We will change row colors that have both Africa for the region and B rank in them.
Steps:
- Go to the New Formatting Rule window and apply the following formula:
=AND($D4="Africa",$E4="B")
- Set the formatting style and click OK to format the cells.
- Here’s the result.
Read More: Conditional Formatting on Multiple Rows Independently in Excel
Things to Remember
You can clear the rules once the formatting is applied
Use the Absolute Cell references ($) for column references to ensure that the conditional formatting is applied on the row.
Download the Practice Workbook
Similar Articles to Explore
- Highlighting Row with Conditional Formatting Based on Date in Excel
- Conditional Formatting Based on Date in Another Cell in Excel
- How to Apply Conditional Formatting to Each Row Individually
- How to Apply Conditional Formatting to Multiple Rows
- Excel Conditional Formatting for Dates within 30 Days
- Excel Conditional Formatting Based on Date
- Apply Conditional Formatting for Dates Older than Today
- Apply Conditional Formatting to Overdue Dates in Excel
<< Go Back to Conditional Formatting Rows | Conditional Formatting | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!
I currently have a formula on my dates to turn red once 7 days overdue. However, if I want to turn the dates back to black once the cell has been filled with green paint, how can I code this in?
Thanks
Dear Iona
Thanks for visiting our blog and sharing your requirements! I have reviewed your goal and created an Excel VBA Event procedure (assuming your dates are in column A).
Excel VBA Event Procedure:
Right-click on the sheet name tab, paste the given code into the sheet module and save it. Hopefully, the idea will fulfil your goal; good luck.
Regards
Lutfor Rahman Shimanto
Excel & VBA Developer
ExcelDemy
Trying to conditionally format a cell to shade when a formula result from another column [@DATE] equals either Saturday or Sunday and it’s the formula in the first column that is blocking that conditional formatting. Can you write conditional formatting based on a cell that is using a formula itself?
Hello Sandy,
You can use this formula:
=OR(WEEKDAY([@DATE], 2) = 6, WEEKDAY([@DATE], 2) = 7)
This checks if the [@DATE] column value is a Saturday (6) or Sunday (7).
Regards
ExcelDemy