View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Les Stout[_2_] Les Stout[_2_] is offline
external usenet poster
 
Posts: 396
Default Color alternate Entire row dependant on value in "A"

Sub test()
Dim rngToColour As Range
Dim varLastValue As Variant
Dim intColour1 As Integer
Dim intColour2 As Integer
Dim intCurrentColour As Integer
Dim LstRow As Long
intColour1 = 2
intColour2 = 3
intCurrentColour = intColour1
LstRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
Set rngToColour = Sheet1.Range("A2:P" & LstRow)
varLastValue = rngToColour.Value(1, 1)
Do While rngToColour.Value("A2:P" & LstRow) < ""
rngToColour.Interior.ColorIndex = intCurrentColour
If rngToColour.Value("A2:P" & LstRow) < 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

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***