View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_2_] Nigel[_2_] is offline
external usenet poster
 
Posts: 735
Default Color rows by "group"

Try this.......I set it to process Sheet1, change as required.

Sub Shader()
Dim c As Range, xc As Integer
xc = 15
With Sheets("Sheet1")
For Each c In .Range("G11:G" & .Cells(.Rows.Count, "G").End(xlUp).Row)
' toggle fill
If c.Value < c.Offset(-1, 0).Value Then
If xc = 0 Then xc = 15 Else xc = 0
End If
' set fill
With .Rows(c.Row).EntireRow.Interior
.Pattern = xlSolid
.ColorIndex = xc
End With
Next c
End With
End Sub

--

Regards,
Nigel




"CLR" wrote in message
...
Hi All.....
I would like to alternate the row color from gray to none, for each group
of
rows according to the value in the cells in column G. That is, starting
with
row 11, I want no background color, then if G12=G11, likewise row 12
would
have no color, but if G12<G11, then the background color of row 12 would
switch to gray. Likewise progressing down column G, as the values change
from the one above it, so does the row color, if the values are the same
as
the one above, the row color would stay the same as the one above. The
entire column is sorted in order so there would be no like values showing
up
out of order. The length of column G will be unknown.

Example
row Col G Color
11 aa none
12 aa none
13 bb gray
14 cc none
15 cc none
16 cc none
17 dd gray
18 dd gray
19 ee none

TIA
Vaya con Dios,
Chuck, CABGx3