Learn how to quickly highlight the entire row based on a single cell's value in Excel. 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 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.
How to change a row color based on a number in a single cell
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 to highlight orders with Qty. larger than 4:
=$C2>4
And naturally, you can use the less than (<) and equal to (=) operators to find and highlight rows that have Qty. smaller than 4 or equal to 4:
=$C2<4
=$C2=4
Also, pay attention to the dollar sign $ before the cell's address - it is needed 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.
How to apply several rules with the priority you need
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. In this case, use this formula:
=$C2>9
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.
How to change a row color based on a text value in a cell
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 function that works for the partial match as well:
=SEARCH("Due in", $E2)>0
In the formula, E2 is the address of the cell that you want to base your formatting on, the dollar sign ($) is used to lock the column coordinate, and >0 means that the formatting will be applied if the specified text ("Due in" in our case) is found in any position in the cell.
Create three such rules following the steps from the first example, and you will have the below table, as the result:
Highlight row if cell starts with specific text
Using >0 in the above formula means that the row will be colored no matter where the specified text is located in the key cell. For example, the Delivery column (F) may contain the text "Urgent, Due in 6 Hours", and this row will be colored as well.
To change the row color when the key cell starts with a particular value, use =1 in the formula, e.g.:
=SEARCH("Due in", $E2)=1
in this case, the row will only be highlighted if the specified text is found in the first position in the cell.
For this conditional formatting rule to work correctly, make sure 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 tool for Excel.
How to change a cell's color based on a value of another cell
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 highlight rows 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).
Highlight rows based on several conditions
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 functions 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 function, 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. For example:
=OR($F2="Due in 1 Days", $F2="Due in 3 Days", $F2="Due in 5 Days")
Tip: Now that you know how to color cells to differentiate between various types of values, you may want to know how many cells are highlighted in a certain color and calculate the sum of values in those cells. The good news is that you can automate this too and you will find the solution in this article: How to count, sum and filter cells by color in Excel.
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.
546 comments
The entire sheet or selected cells change color instead of only the supposed impacted row.
I am selecting exactly as mentioning on the tutorial.
Is someone having the same issue?
Hi! I think that you are doing something that is different from what is described in the user guide. Describe in more detail what you are doing and what is the conditional formatting formula that you are using.
I actually did as described in the tutorial.
In a tab, I made a column called Status with a dropdown picking status from another tab called DATA
I'd like my line to change to green when the cell in column L to change to DONE
It works when I do it on one line, but when copying the conditional formatting to my entire sheet, it colours the entire sheet to green.
More precision: when I select DONE on the Conditional formatting line I made the rule for, it colours the entire sheet green instead of copying the conditional formatting to each line separately.
I'd like to avoid creating a separate conditional formatting rule for each line of my sheet.
Hi! Instead of applying a conditional formatting rule to a single cell, create a conditional formatting rule for a range of cells.
For example, apply rule =$L2="DONE" to range A2:Z100.
To do this, first select the range of cells that you want to apply and then create a conditional formatting rule. It will apply to the whole range, not just one cell.
Exemple:
In applies to:
I enter =A45:L45
When i click apply, Excel re write =$A$45:$L$45
My formula is correct since it works on the applied line.
But it needs to be recreated, and isn't independent line per line.
I can't find comments online with similar issues, so seems like I am the only one having this issue on Office 365?
I gave you an example of a conditional formatting formula to apply to a range of cells. But I can't see what you're actually doing. You will find all the information you need in the article above and in the recommended articles.
When you specify a conditional formatting range, it is normal. Make sure that the mixed reference is correctly written in the conditional formatting formula.
Yes, that's what I did but it colours the entire cell within range A2 to Z100 in green.
Actually I figured out there are $ signs in my formulas and I can't remove them. When I apply the conditional formatting, Excel adds them again. Might be why I am stuck.
Any tips on how to avoid excel adding $ everywhere ?
Hi! Please take a look at this article: Relative and absolute cell references in Excel conditional formatting.
Here are instructions on how to change an absolute cell reference to mixed cell reference: Switching between different reference types.
Thank you very much,it useful
This was enormously helpful. Very clear and covered all the bases.
i want to have the rows grade colored based of the value of a cell on that row
Please read the above article carefully.
Did the biz for me. Thanks for the clear and well illustrated instructions.
also should be =$G1>0 and for the other rule =$G1<0
It doesn't work at all
My goal is to set one bacround color for every row where colum G is less than zero
And another color when column G is greater than zero
So I've create two rules
="$G0"
I want to apply the rules on the whole sheet : I dont know how to do it appearently the rules only exists on one row
And there is no result at all
I'm a C# developper but totally stupid with excell
Thanks if someone can help me
Hi! If you read the instructions in the first paragraph of this article carefully, first select the cells (or the entire worksheet) where you want to change the color by condition. Then create a conditional formatting rule.
select the whole sheet before setting up the rule
I am trying to set it up so that when I input text into a certain column it changes the whole row to a certain color. For example, I have 2 columns that i need this for. One column is "APPROVED" and the other is "DELIVERED". For the APPROVED column when i input the text for who approved it (name) and the date i need that whole row to change to a certain color. For the DELIVERED column when i input the date i need it to change to a different color than the APPROVED column. I hope that makes sense.
Hi! All the information you need to change the color of a row by condition is in the article above. To change the color of a cell by condition, use these recommendations: Excel conditional formatting formulas based on another cell. Create the first conditional formatting rule for a row and the second rule for a cell.
thx for ur sharing
thanks for sharing
Hello,
I would like the row in my spreadsheet to change colors once a date has been added to the "Date Complete" column. I have tried using =CELL("format",$D2)="D1" type formula, but have found that since I have formatted the cells in column D, the entire spreadsheet changes color. How can I get the row to change color if there is a date in the column, and not change color if there is no date in the column?
Hello! Try adding a second condition: the cell must contain a number. Use ISNUMBER function.
=(LEFT(CELL("format",$D2),1)="D")*ISNUMBER(D2)
Hi, I'm trying to set up colours for a particular 'status letter' which is in Column E, to colour cells/rows from columns A to E. For example, the letter 'P' in cell 2E, I want cells on row 2 from A2 - E2, to be a light blue; Then the following letters, still in column E, to have the same formatting, but a different colour. F is green, C is red, B is orange & R to have the font changed to red.
I'm having trouble searching for an answer with your examples above.
Can you help please.
thanks.
IT'S OK. Pls disregard. I worked it out. thanks.
I'm trying to have rows turn grey if the customer enquiring is outside of our coverage area (multiple post codes) so can it do it saying if the cell doesn't contain NR or IP it turns the whole row grey?
Hi! Please try the following conditional formatting formula:
=OR(ISNUMBER(SEARCH("NR",A1)),ISNUMBER(SEARCH("IP",A1)))
For more information, please read: How to find substring in Excel
Hello!
I am trying to create a Gantt style chart to track the progress of some upcoming projects and it has been requested that the actual completion date be a different color based on where it falls in the 'allowable timeframe'.
The below formula adds a corresponding filled cell in the calendar side but I am only able to figure out how to do it in one color. I would like to be able to do it in Green, Amber and Red based on how it falls in comparison to the completed date.
=AND(Actual_Completion_Date4>=M$9,Actual_Completion_Date4<N$9)
I have scoured online and would consider myself to have a pretty decent knowledge of Excel, I am coming up blank on this solution. I am not opposed to have multiple formulas in order to get the different colors.
ANY assistance you may be able to provide would be greatly appreciated!
Hello! If I understand the question correctly, you can create a conditional formatting formula for each color. For more information, please read: Excel conditional formatting formulas based on another cell.
Hello,
Is there a particular formula that allows me to have the whole row turn a color (grey for my purposes) if any text is entered in a particular box? I understand the conditional formatting process but want the line to be greyed out automatically when any date is entered into my "DATE CLOSED" box.
Thanks,
Lauren
Please re-check the article above since it covers your case.
searching for the same thing. you are not helping
Describe your unique case that you did not find the answer to in the article above.
Could you please share the video
On the Spreadsheet I'm making I'm trying to make an entire row change based on whether one cell says "Resolved" or "Not Resolved", I have used the Formula described above, =$B2="Resolved" and =$B2="Not Resolved" Which then Applies to =$A$2:$J$2 but only the cell where the text is Written is colored the rest stay blank
Hi!
I have not been able to replicate your problem. Apply the =$B2="Resolved" rule to the range =$A$2:$J$2 or =$A$2:$J$10
How would I add a color to a portion of a row based upon whether there a cell has information in it or not?
What I'm trying to do is grey out a row if no info has been added to specific cell. Cell 3C has dates in it, but not all rows have dates in the C column. If 3C had no data, I'd like the whole row from 3A-3G to change to grey so it is readily apparent that that line has no information about it. Do you have a suggestion as to how I'd write the formula?
Hi!
Have you tried the ways described in this blog post? The tutorial above contains answers to your question.
For example -
=ISBLANK($C1)
Hi
How do I get a whole column to highlight red when anything equal to or above 8 is reached in only one cell within this column. This is relating to a staffing sheet - 8 is our limit for staff annual leave in our particular workplace so anything equal to or above is a concern.
Hi!
Select a column and use a conditional formatting formula
=A1>8
All the necessary information is in the article above.
How do you highlight a row just based on a particular cell having text in it? I have a spreadsheet that I want the row to highlight once a date is entered into a cell in column D. I do not know how to make a formula for that.
Hi!
Please re-read the article above, it covers your case completely.
Something like =$D1:$D9999="TEXT" should work for what you are looking for. You can use whatever start/end range for Column D you need and enter the desired text in quotes.