Row color by grouping?
Here it is in code if you are using conditional formats already for a
different purpose. You will probably want to cahnge the colours which just
requires changing intCoulour1 and intColour2. These should really be
constants anyway...
Sub test()
Dim rngToColour As Range
Dim varLastValue As Variant
Dim intColour1 As Integer
Dim intColour2 As Integer
Dim intCurrentColour As Integer
intColour1 = 2
intColour2 = 3
intCurrentColour = intColour1
Set rngToColour = Sheet1.Range("A2:C2")
varLastValue = rngToColour.Value(1, 1)
Do While rngToColour.Value(1, 1) < ""
rngToColour.Interior.ColorIndex = intCurrentColour
If rngToColour.Value(1, 1) < varLastValue Then
If intCurrentColour = intColour1 Then
intCurrentColour = intColour2
Else
intCurrentColour = intColour1
End If
varLastValue = rngToColour.Value(1, 1)
End If
Set rngToColour = rngToColour.Offset(1, 0)
Loop
End Sub
HTH
"guy" wrote:
I have some product codes in 3 columns that are sorted. I would like to alternate the color of rows
when a product code changes. How done?
|