Excel.Tips.Net ExcelTips (Menu Interface)

Shading Rows for Ease in Reading Output

Those who have been around computers long enough may remember the days of green-bar paper. That's not to slight any places that may still be using green-bar; its just that the hey-day of such paper seems to be past. The need for such paper, particularly when dealing with numeric printouts, is still present however.

What green-bar paper did (for those who don't know) was provide a visual cue for your eyes so that you could easily follow a row of numbers across the width of the paper, without the human tendency of skipping from one row to another. You may still use some device to help you read rows of numbers--for instance, a ruler held under the row to guide your eyes.

If you find yourself pulling out the ruler more often or wishing for the return of green-bar paper, then you may be interested in a little macro I whipped up to help. The following macro, ShadeRows, will shade every fifth row in the rows you select. This means that the first, sixth, eleventh, and so on rows will be shaded.

Sub ShadeRows()
    Dim iStart As Integer
    Dim iEnd As Integer
    Dim iStep As Integer, J As Integer

    iStep = 5         'Shade every 5th row
    Application.ScreenUpdating = False
    iStart = 1
    iEnd = Selection.Rows.Count

    For J = iStart To iEnd Step iStep
        With Selection.Rows(J).Interior
            .ColorIndex = 15
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
        End With
    Next J
    Application.ScreenUpdating = True
End Sub

To run the macro, just select the rows you want to affect, and then run it. If you want to change the interval at which rows are shaded, change the iStep value from 5 to some other value. For instance, if you wanted every other row shaded, you would change iStep = 5 to iStep = 2.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2130) applies to Microsoft Excel 97, 2000, 2002, and 2003.

Related Tips:

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!


Leave your own comment:

  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*What is 5+3 (To prevent automated submissions and spam.)
           Commenting Terms

Comments for this tip:

Lester    12 Dec 2011, 13:34
To shade every other row, which is my preference, first select the region/area to be formatted and then type the following conditional formatting formula and select your chosen color.

Kent    12 Dec 2011, 07:00
Cutting and pasting within the spreadsheet has never been a problem as the row markings appear unaffected.

I am a big user of Paste Special when bringing in data from outside so so maybe that may be why I have never seen anything unintended.
Dean     11 Dec 2011, 13:23
Doesn't the Conditional Formtting get messed up when cuttng or pasting to fill in data?
Kent    11 Dec 2011, 09:38
Another option for the macro challenged is to conditionally format the rows.

My favourite is 3 shaded, 3 unshaded which can be achieved by with a Conditional Format: Forumula Is =MOD(ROW()-6,3*2)+1<=3

By changing the various components after MOD all sorts of different styles can be set.

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us


Advertise with Us

Our Privacy Policy

Our Sites


Beauty and Style




DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)



Home Improvement

Money and Finances


Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives


Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.