Got it working! Here's the final code. I actually have two named
ranges on each worksheet, so the code performs the highlighting for
each.

###

Dim curWks As Worksheet
Dim r As Long
Dim Range1 As Range
Dim Range2 As Range

Set curWks = ActiveSheet
With curWks

If .Name = ("WS1") Then
    Set Range1 = .Range("WS1DataA")
    Set Range2 = .Range("WS1DataB")
ElseIf .Name = ("WS2") Then
    Set Range1 = .Range("WS2DataA")
    Set Range2 = .Range("WS2DataB")
ElseIf .Name = ("WS3") Then
    Set Range1 = .Range("WS3DataA")
    Set Range2 = .Range("WS3DataB")
ElseIf .Name = ("WS4") Then
    Set Range1 = .Range("WS4DataA")
    Set Range2 = .Range("WS4DataB")
End If

    With Range1
        ' remove any previous shading
        .Interior.ColorIndex = xlColorIndexNone
        ' Shade every second row lt gray (i.e., color index = 15)
         For r = 2 To .Rows.Count Step 2
            .Rows(r).Interior.ColorIndex = 15
        Next r
    End With

    With Range2
        ' remove any previous shading
        .Interior.ColorIndex = xlColorIndexNone
        ' Shade every second row lt gray (i.e., color index = 15)
         For r = 2 To .Rows.Count Step 2
            .Rows(r).Interior.ColorIndex = 15
        Next r
    End With

End With
End Sub

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to