Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Shading Rows with Conditional Formatting.

Shading Rows with Conditional Formatting

by Allen Wyatt
(last updated January 7, 2017)

13

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:

  1. Select the data whose alternating rows you want to shade.
  2. Make sure the Home tab of the ribbon is displayed.
  3. Click the Conditional Formatting tool. Excel displays a series of choices.
  4. Click New Rule. Excel displays the New Formatting Rule dialog box.
  5. In the Select a Rule Type area at the top of the dialog box, choose Use a Formula to Determine Which Cells to Format. (See Figure 1.)
  6. Figure 1. The New Formatting Rule dialog box.

  7. In the formula space, enter the following formula:
  8. =MOD(ROW(),2)=0
    
  9. Click on the Format button. Excel displays the Format Cells dialog box.
  10. Make sure the Fill tab is selected. (See Figure 2.)
  11. Figure 2. The Fill tab of the Format Cells dialog box.

  12. Select the color you want used for the row shading.
  13. Click on OK to close the Format Cells dialog box.
  14. Click on OK to close the New Formatting Rule 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.

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Intelligent Title Case

A common editorial need is to change the capitalization used on different words in a selection of text. Word provides a ...

Discover More

Copying Rows and Columns with the Mouse

Word allows you to do quite a few editing tasks using the mouse. If you want to copy rows or columns in a table, you can use ...

Discover More

Displaying a Number as Years and Months

How do you display a number of years, such as 3.67 years, as a number of years and months? It's simple to do with a formula, ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

Conditionally Formatting Cells Containing Dates

Need to know if a particular cell contains a date value? Excel doesn't have a worksheet function to determine this ...

Discover More

Automatic Lines for Dividing Lists

When preparing a report for others to use, it is not unusual to add a horizontal line between major sections of the report. ...

Discover More

Deleting Conditional Formatting

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 More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is seven less than 7?

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.


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.