*Learn how to quickly change the color of the entire row based on a single cell's value in your Excel worksheets. Tips and formula examples for number and text values.*

Last week we discussed how to change the background color of a cell based on its value. In this article you will learn how to highlight entire rows in Excel 2016, 2013 and 2010 based on a value of one cell, and also find a few tips and formula examples that will work with numerical and text cell values.

Say, you have a table of your company orders like this:

You may want to shade the rows in different colors based on the cell value in the *Qty.* column to see the most important orders at a glance. This can be easily done using Excel Conditional Formatting.

- Start with selecting the cells the background color of which you want to change.
- Create a new formatting rule by clicking
*Conditional Formatting*>*New Rule…*on the*Home*tab.

- In the "
*New Formatting Rule*" dialog window that opens, choose the option "*Use a formula to determine which cells to format*" and enter the following formula in the "*Format values where this formula is true*" field:`=$C2>4`

Instead of

*C2*, you enter a cell that contains the value you want to check in your table and put the number you need instead of*4*. And naturally, you can use the less (<) or equality (=) sign so that your formulas will read`=$C2<4`

and`=$C2=4`

, respectively.Also, pay attention to the dollar sign

**$**before the cell's address, you need to use it to keep the column letter the same when the formula gets copied across the row. Actually, it is what does the trick and applies formatting to the whole row based on a value in a given cell. - Click the "
**Format…**" button and switch to*Fill*tab to choose the background color. If the default colors do not suffice, click the "**More Colors…**" button to pick the one to your liking, and then click*OK*twice.

You can also use any other formatting options, such as the font color or cells border on the other tabs of the

*Format Cells*dialog. - The preview of your formatting rule will look similar to this:

- If this is how you wanted it and you are happy with the color, click
*OK*to see your new formatting in effect.Now, if the value in the

*Qty.*column is greater than 4, the entire rows in your Excel table will turn blue.

As you can see, changing the row's color based on a number in a single cell is pretty easy in Excel. Further on, you will find more formula examples and a couple of tips for more complex scenarios.

In the previous example, you may want to highlight the rows with different values in the *Qty.* column in different colors. For example, you can add a rule to shade the rows with quantity 10 or greater, say, in pink. In this case, use the formula `=$C2>9`

, and after your second formatting rule is created, set the rules priority so that both of your rules will work.

- On the
*Home*tab, in the*Styles*group, click*Conditional Formatting*>*Manage Rules…*. - Choose "
*This worksheet*" in the "*Show formatting rules for*" field. If you want to manage the rules that apply to your current selection only, choose "*Current Selection*". - Select the formatting rule you want to be applied first and move it to the top of the list using the arrows. The result should resemble this:

Click the

*OK*button and the corresponding rows will immediately change their background color based on the cell values that you specified in both formulas.

In our sample table, to make follow-up on orders easier, you can shade the rows based on the values in the *Delivery* column, so that:

- If an order is "Due in X Days", the background color of such rows will turn orange;
- If an item is "Delivered", the entire row will be colored in green;
- If an order is "Past Due", the row will turn red.

Naturally, the row color will change if the order status gets updated.

While the formula from our first example could work for "Delivered" and "Past Due"(`=$E2="Delivered"`

and `=$E2="Past Due"`

), the task sounds a bit trickier for "Due in…" orders. As you see, different orders are due in 1, 3, 5 or more days and the above formula won't work because it is purposed for exact match.

In this case, you'd better use the *=SEARCH* formula like this `=SEARCH("Due in", $E2)>0`

that works for the partial match as well. In the formula, *E2* is the address of the cell that you want to base your formatting on, the dollar sign (*$*) is used to apply the formula to the entire row, and *>0* means that the formatting will be applied if the specified text ("*Due in*" in our case) is found.

If you want to change the color of rows where the contents of the key cell **starts** with the indicated value or text, then you need to use **=1** in the formula, e.g. `=SEARCH("Due in", $E2)=1`

. However, be very careful when using this kind of formula and ensure that there are no leading spaces in the key column, otherwise you might rack your brain trying to figure out why the formula does not work :) You can use this free tool to find and remove leading and trailing spaces in your worksheets - Trim Spaces add-in for Excel.

Create three such rules following the steps from the first example, and you will have the below table, as the result:

In fact, this is simply a variation of changing the background color of a row case. But instead of the whole table, you select a column or a range where you want to change the cells color and use the formulas described above.

For example, we could create three such rules to shade only the cells in the "*Order number*" column based on another cell value (values in the *Delivery* column).

If you want to shade the rows in the **same color based on several values**, then instead of creating several formatting rules you can use the **=OR** or **=AND** formulas to set several conditions.

For example, we can color the orders due in 1 and 3 days in the reddish color, and those that are due in 5 and 7 days in the yellow color. The formulas are as follow:

`=OR($F2="Due in 1 Days", $F2="Due in 3 Days")`

`=OR($F2="Due in 5 Days", $F2="Due in 7 Days")`

And you can use the **=AND** formula, say, to change the background color of rows with *Qty.* equal to or greater than 5 and equal to or less than 10: `=AND($D2>=5, $D2<=10)`

.

Naturally, you are not limited to using only 2 conditions in such formulas, you are free to use as many as you need, e.g. `=OR($F2="Due in 1 Days", $F2="Due in 3 Days", $F2="Due in 5 Days")`

and so on.

These are only a few of many possible ways to zebra stripe your Excel worksheets based on a cell's value that will respond to change of data in that cell. If you need something different for your data set, drop us a comment and we will try to figure this out.

Excel formulas
CSV
Excel functions
Print
Financial functions
Vlookup
Merge data in Excel
SumIf
CountIf
Excel Compare
If statement
Excel Charts
Pivot Table
Conditional formatting
Excel formatting
Excel duplicates
Excel date
Excel tips
Excel macro
Outlook
Google Sheets
Outlook duplicates
Shared email templates

Category: Excel Tips

60+ professional tools for Excel

2019–2010 to do your daily work

2019–2010 to do your daily work

Incredible product, even better tech support…AbleBits totally delivers!

Deborah Bryant

Anyone who works with Excel is sure to find their work made easier

Jackie Lee

The best spent money on software I've ever spent!

Patrick Raugh

Ablebits is a fantastic product - easy to use and so efficient.

Debra Celmer

Excel is at its best now

Annie C.

I don't know how to thank you enough for your Excel add-ins

Jennifer Morningstar

Anybody who experiences it, is bound to love it!

Kumar Nepa

AbleBits suite has really helped me when I was in a crunch!

Nelda Fink

I have enjoyed every bit of it and time am using it

Christian Onyekachi Nwosu

It's the best $100 we've ever spent!

Mike Cavanagh

I love the program, and I can't imagine using Excel without it!

Robert Madsen

One word… WOW!

Dave Brown

Love the products!

David Johnston

It is like having an expert at my shoulder helping me…

Linda Shakespeare

Your software really helps make my job easier

Jeannie C.

Thanks for a terrific product that is worth every single cent!

Dianne Young

I love your product

Brad Gibson

Awesome!!!

Sheila Blanchard

## 473 responses to "How to change the row color based on a cell's value in Excel"

I am working on a excel that has two sheets. I have data on the second sheet, specifically a list of names in a table. What I would like to happen is then I enter the name on first sheet, it highlights the name. I've tried a few conditional formatting attempts, but nothing has been working. Wondering what I'm doing wrong. Thanks!

This will not work if the cell was set via conditional formatting. Do you have a workaround?

Hi

i have different colours in rows A2,A3,A4 like Yellow, Blue and Green. When i format A1 as Red then A2,A3,A4 colour should be removed.

Is this possible

Thanks

Hi Team,

Can someone help me with VB code where only those rows should be highlighted which are in amber color under my excel sheet

in a scenario where you want to give range for change of cell color wherein value of cell is more than 1 but less than 26. how to implement it on sheet containing a lot of values.

thanks

hi

i need a formula which can copy a text which ahve already conditional formating and (text of the cell are in red color), to paste on other sheet which also paste the text in red color

Hi, if I want to leave the cells with out a color until I fill in any data, how do I proceed with that?

Hello Asta!

Hello

You can learn more about conditional formatting in Excel in this article on our blog.

https://www.ablebits.com/office-addins-blog/2013/10/18/change-background-color-excel-based-on-cell-value/

Hope you’ll find this information helpful.

Hi, Thank you for this detailed explanation, I was able to follow it easily. It seems mine isn't quite working properly though. We have a quote tracker, and we change the status to "Sold", "On Hold", or "Denied" in column P starting at row 5. When I change the status in cell P:5 to "Sold" it is supposed to change just row 5 to green but it changes all the rows down to row 500. My formula is =$P$5="Sold", turn to Green fill dark green text, applies to $A$5:$Q$500. There are 500 rows in our sheet and columns up to Q. If I change the formatting to =$P$5="Sold", turn to Green fill dark green text, applies to $A$5:$Q$5 it works correctly and only highlights row 5 when I change the status to "Sold". The problem with that is when I change the status to "Sold" in row 6 nothing happens. I hope I don't need to add a rule for each row?

I figured it out! My mistake was the fact I had =$P$5="Sold". The two dollar signs were the issue. It should be =$P5="Sold". Thanks for this tutorial!

Hello Darren,

If I understand your task correctly, please try the following formula:

= $P5 = "Sold"

You can learn more about Relative and absolute cell references in Excel conditional formatting rules in this article on our blog. Hope you’ll find this information helpful.

on the basis of blank cell in a column, I want the row being highlighted. plz guide

Hello!

Please read this article about conditional formatting.

Pay attention to conditional formatting for empty and non-empty cells.

Hello Svetlana ...

i have a problem with data in excel. How to

change the color of the text to red when it exceeds 100 characters and those less than 100 characters remain black

Thank you

Particluars VALUE VALUE

APPLE YES YES

ORANGE NO NO

GRAPE NO YES

MANGO YES NO

I want to change the color of these cells YES YES in green color, NO NO in red color, NO YES in orange color, YES NO in orange color. please assist.

Hello!

All that needs to be done when conditionally formatting a string by cell values is described in detail in this article.

Hello!

Can you help ?

I'm looking for solution coloring a cell, or cells regarding a third party cell value.

Example:

If cell A1 is 100% or greater, color cell A2:A4 with Green.

Thanks in advance

Hello Amir!

The answer to your question is in the article above. Read carefully - How to change a row color based on a number in a single cell

How to I apply a color to a single text in a row in excel?

For example: Miniature doll clothing, dress, size 1

I want the no. 1 in red on various rows.

Then, let's say the rest of my 20 rows, the size is size 2, so I want the no. 2 in green

What formula do I use and how?

Thanks

Hello!

I hope you have studied the recommendations in the above tutorial.

Use conditional formatting with a formula. Set the text color to red when this condition is met:

=NOT(ISERROR(SEARCH("1",A1,1)))

For green, use the formula

=NOT(ISERROR(SEARCH("2",A1,1)))

I hope it’ll be helpful.

Hello,

I can follow the tutorial above and get it to work on a single value on the same sheet, but I am trying to colour a row based on a cell value in a range of numbers on a 2nd sheet.

ie, on sheet 1 & 2 are cells in column A numbered with a hash+number #1 , #2, #3 etc.

If #2 is present in the range of A2:A5000 on Sheet 2, then colour the row with #2 only on Sheet 1.

Any help would be greatly appreciated thank you

Hello!

Unfortunately, without seeing your data it hard to give you advice. Please specify what formula you used and what problem or error occurred. Give an example of the source data.

It’ll help me understand it better and find a solution for you.

I have excel sheet and one column I have renewal date. I want to highlight this row before one month

So I can I use this conditional formatting

Please revert on my email

Hello!

Read how to highlight dates within a date range.

Hope you’ll find this information helpful.

Hello Madam / Sir,

I have a rota for our department. So, each name appears in different cell / different column, multiple times across the sheet.

Please advice, How can I change the colour of the row depending on the name, which can appear in any cell across the sheet?

Secondly, can I have a drop down cell with various names,,,, and depending on which name I select in that cell, can I ensure that the row with that name changes colour?

Please advice

Thanks

Hello!

For each name, you can use something like this conditional formatting formula. Set a different color for each name.

=COUNTIF(2:2,"Mike")>0

In the case of a cell reference in a formula:

=COUNTIF(2:2,$A$1)>0

I hope my advice will help you solve your task.

thank you very much, it really helped.

I cannot get a pivot table based upon time to conditional format. I have reformatted the numbers to be "general", Time, Custom (mm:ss), text and nothing works. When I use a formula that is built-in, such as "higher than", it highlights the whole column, not distinguishing between values.

Excel 16 Conditional Formatting of time within pivot tables is really difficult!

Hello!

Please have a look at this article — Excel conditional formatting for dates & time.

Hope you’ll find this information helpful.

Hello, Is it possible to apply the varied colors of cells to the points they're representing on a graph (via point color or label)?

thanks

I have to make RM coverage sheet if have 50 nos RM in stock and I am consuming daily 10 nos. Then remaining days should be shown in coloured pls. Suggest for the same

HI there,

I have an excel sheet with columns and want to add another which will have date of expiry in them. I would like that these dates are changed automatically when we get to a month before expiry date to amber and red once its past the date, how can I do this???

Hello!

Please check out the following article on our blog, it’ll be sure to help you with your task: How to conditionally format dates and time in Excel.

I am using the formula below to try and format rows of data if the number in column C happens to also be in column A of Sheet 1. However, it's only highlighting the first row that meets that condition. All of the other rows that meet the condition are not changing color. Any suggestions?

=$C2=Sheet1!$A:$A

Hello!

If I got you right, the formula below will help you with your task:

=MATCH($C2,Sheet1!$A$1:$A$100,0)

You can learn more about MATCH function in Excel in this article on our blog.

Hi,

I want to change cell value based on color and the option available in conditional formatting is in reverse way. Can you suggest.

Thank you.

Hi,

If I understand your task correctly, pay attention to the following paragraph of the article above — "How to apply several rules with the priority you need"