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)


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. ...


Inserting a Section Mark

Section marks are used regularly in the writings of some industries, such as in legal documents. If you need a way to ...

Discover More

Changing the Language Setting for All Document Text

Word supports a number of different languages for documents you create. If you need to routinely change the language used ...

Discover More

Using Only Odd Page Numbers

Do you need to number the pages of your document using only odd page numbers? Word doesn't provide a way to do this, but ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Defining a Single Condition

Conditional formatting is a powerful tool you can use to dynamically adjust the formatting of your worksheet. This tip ...

Discover More

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

Changing Shading when a Column Value Changes

If you have a data table in a worksheet, and you want to shade various rows based on whatever is in the first column, ...

Discover More

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

View most recent newsletter.


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 three more than 8?

2017-01-27 12:01:40

Willy Vanhaelen


You probably skipped step 1. "Select the data (range) whose alternating rows you want to shade.".

2017-01-26 13:23:35


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


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


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


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.

Also lots of good tips on this page.

2017-01-07 15:28:24


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


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


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


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


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.
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

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.