how do you colour alternate visible rows only

D

Don Guillett

try this

Sub colorvisiblerows()
x = Range("a" & Rows.Count).End(xlUp)
Rows("1:" & x).Interior.ColorIndex = xlNone
For i = 2 To x Step 2
Cells(i, 1).SpecialCells(xlCellTypeVisible) _
.EntireRow.Interior.ColorIndex = 6
Next i
End Sub
 
D

David Turner

Don Guillett wrote
Sub colorvisiblerows()
x = Range("a" & Rows.Count).End(xlUp)
Rows("1:" & x).Interior.ColorIndex = xlNone
For i = 2 To x Step 2
Cells(i, 1).SpecialCells(xlCellTypeVisible) _
.EntireRow.Interior.ColorIndex = 6
Next i
End Sub

I was interested in this routine as well, but keep getting a 'Type
mismatch' error in this line:

Rows("1:" & x).Interior.ColorIndex = xlNone
 
D

David Turner

David Turner wrote
Don Guillett wrote


I was interested in this routine as well, but keep getting a 'Type
mismatch' error in this line:

Rows("1:" & x).Interior.ColorIndex = xlNone

Never mind. Changed first line to

x = Range("a" & Rows.Count).End(xlUp).Row

and now it works
 
Top