How can I shade every other row with some rows hidden (autofilter
You really only want to shade every other visible row. So use this condition
in you logic:
Sub alter()
Dim L As Long, pong As Boolean
pong = True
For L = 1 To 100
If Rows(L).EntireRow.Hidden = False Then
If pong Then
Rows(L).Interior.ColorIndex = 2
Else
Rows(L).Interior.ColorIndex = 4
End If
pong = Not pong
End If
Next L
End Sub
Autofilter make rows hidden, so we skip hidden rows when painting alternate
colors.
--
Gary''s Student
"dlindamood" wrote:
How can I shade every other row of an excel spredsheet. Some of the rows are
hidden with the auto filter on. My results always end up with the even rows
gray and the odd rows clear. With the autofilter on, some times the odd rows
are adjacent, and sometimes the even rows are adjacent. This results in a
random coloring of the rows.
|