ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I shade every other row with some rows hidden (autofilter (https://www.excelbanter.com/excel-programming/357155-re-how-can-i-shade-every-other-row-some-rows-hidden-autofilter.html)

Gary''s Student

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.



All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com