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 June 7, 2021)


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.


If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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


Workbook not Saving

Having trouble saving a workbook? It could have to do with the age, size, and complexity of that workbook. This tip ...

Discover More

Inserting the Current Time with Seconds

If you need to insert the current time, with seconds, then you'll need the macro discussed in this tip. It's easy to use ...

Discover More

Automatically Identifying Repeated Words

Need to find out how many times words are repeated in a document? If so, you'll appreciate the discussion in this tip ...

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)

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

Converting Conditional Formatting to Regular Formatting

Conditional formatting allows you to change how information is displayed based on rules you define. What if you want to ...

Discover More

Conditional Formats for Odd and Even Columns

Setting up conditional formatting can be challenging under some circumstances, but once set it can work great. Unless, of ...

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}] (all 7 characters, in the sequence shown) 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 four less than 5?

2021-06-09 10:27:09

J. Woolley

To shade every other pair:

2021-06-08 15:10:15


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


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


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.