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

Determining an Integer Value

When creating macros, you often need to process numbers in various ways. VBA allows you to convert a numeric value to an ...

Discover More

Modifying Proper Capitalization

The PROPER worksheet function is used to change the case of text so that the first letter of each word is capitalized. If ...

Discover More

Creating Endnotes

Endnotes are often used in scholarly or legal documents, and they can be added easily. This tip shows how to add them ...

Discover More

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!

More ExcelTips (ribbon)

Highlighting Cells Containing both Letters and Numbers

Conditional formatting is a great tool for changing the format of cells based on whether certain conditions (rules) are true ...

Discover More

Highlighting Cells Containing Specific Text

If you want to highlight cells that contain certain characters, you can use the conditional formatting features of Excel to ...

Discover More

Conditional Format that Checks for Data Type

Conditional formatting can be used to highlight cells that contain the improper type of data for your needs. This tip ...

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 8Mpixels. 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 6 - 3?

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.