If you haven't tried out the conditional formatting features of Excel before, they can be quite handy. One way to use this feature is to cause Excel to shade every other row in your data. This is great when your data uses a lot of columns and you want to make it a bit easier to read on printouts. Simply follow these steps:
Figure 1. The New Formatting Rule dialog box.
=MOD(ROW(),2)=0
Figure 2. The Fill tab of the Format Cells dialog box.
You may wonder why anyone would use conditional formatting to highlight different rows of a table when you can use the table formatting feature (available in the Styles group of the Home tab of the ribbon) to accomplish the same thing. The reason is simple—using conditional formatting provides much more flexibility in the formatting applied as well as in the interval of the rows being shaded.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7363) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Shading Rows with Conditional Formatting.
Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!
After you've applied a conditional format to a cell, you may have a need to later delete that format so that the cell is ...
Discover MoreConditional formatting allows you to change how information is displayed based on rules you define. What if you want to ...
Discover MoreSetting up conditional formatting can be challenging under some circumstances, but once set it can work great. Unless, of ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-06-09 10:27:09
J. Woolley
@Becky
To shade every other pair:
=MOD(ROW()+1,4)<2
2021-06-08 15:10:15
Becky
How would you modify the formula if you want to shade two rows, skip two rows, shade 2, skip 2, etc......
2021-06-07 12:15:09
David Czuba
Here's a tip to make the whole sheet alternating row colors. Instead of selecting just the data you want alternating rows for, use the sheet selector in the upper left (below the name box) to select the entire sheet, and then apply the conditional formatting.
2021-06-07 11:53:03
Russ
Is there any way to write the formula that would keep the alternate row shading when some of the rows are hidden, either by hiding specific rows or by applying filters?
2017-01-27 12:01:40
Willy Vanhaelen
@Tina
You probably skipped step 1. "Select the data (range) whose alternating rows you want to shade.".
2017-01-26 13:23:35
Tina
I tried to do this as a test on a document and while the first line shaded, nothing else did. What am I doing wrong?
2017-01-18 21:46:22
Susan Camac
I love this tip. The formatting stays on alternate lines even when I sort the data. Thank you
2017-01-09 22:36:49
Greg
MOD is the Modulo function. Simply put, a division action is performed ( in this case: ROW / 2 and captures the remainder.
So, if the row # is evenly divisible by 2 ( an even number) you get a Modulo = 0, if the row # is not evenly divisible by 2 ( an odd number ) you get a non zero Modulo.
=MOD(ROW(),2)=0 uses the ROW() function to return the row # of each row in the selected block, then this is divided by 2 and the remainder taken, if the remainder = 0, then the whole statement is "true" and the conditional format will be applied to the row which was tested. If the MOD is NOT equal to 0 then the whole statement is false and the conditonal formating will not be applied.
If you used =MOD(ROW(),1)=0 then all rows would be shaded.
If you used =MOD(ROW(),3)=0 then only rows 3, 6, 9, 12,... etc would be shaded
and so on.
2017-01-09 08:59:52
Jeff
IMO it would be helpful to the readers if the formula were explained (specifically, how the MOD function works) rather than simply listing it.
2017-01-09 08:56:46
Jeff
Ed, I agree. Another "feature" of conditional formatting is the ability to bypass/remove it by pasting into a cell.
2017-01-07 21:17:09
Greg Kinn
Response to Kelly Brown Re:
I think the response to the first comment on this web page answers your question.
http://www.myonlinetraininghub.com/excel-conditional-formatting-zebra-stripes
Also lots of good tips on this page.
http://www.myonlinetraininghub.com/toggle-excel-conditional-formatting-on-and-off
2017-01-07 15:28:24
Erik
Bob, to use this for columns instead, change "row" in the formula to "column". Simple as that. But sorry, the only thing I know about Excel on an Apple device is there are many differences from the Windows version.
2017-01-07 13:57:39
Rosalie
Re: Shading Rows with Conditional Formatting. I couldn't get this to work on 3 tries. What am I missing?
2017-01-07 11:49:05
Bob
I would appreciate advice as to how this formatting can be done using Excel for Mac v15. Also, can this be done for alternate columns?
Thanks, Bob
2017-01-07 10:58:55
Ed
Conditional formatting is a great tool. But, beware if you over use it, like in a large spreadsheet, it can slow thing down considerably.
2017-01-07 06:59:58
Kevin
Kelly
This helper column version changes every time the relevant column value changes (N in the example).
Start with "A" in the cell U6, place this formula in U7, then copy down as required.
=IFERROR(IF(IF(NOT(N7=N6),1,0)=1,IF(U6="A","B","A"),IF(U6="A","A","B")),"")
Set your conditional formatting for the "A" or "B" of column U.
Revise to suit your required columns/rows.
2017-01-07 05:35:30
Kelly Brown
I am seeking a similar formula but instead of shading every nth row, I want to shade a block of rows every time a value in a certain column changes.
I can email an example that was done manually if you like.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2022 Sharon Parq Associates, Inc.
Comments