Skip to content

Instantly share code, notes, and snippets.

@jsanti
Created August 25, 2010 04:36
Show Gist options
  • Save jsanti/548863 to your computer and use it in GitHub Desktop.
Save jsanti/548863 to your computer and use it in GitHub Desktop.
' Color row grops in Excel with alternating colors
Public Sub HighLightRows()
Dim i As Integer
i = 3
Dim color1 As Integer
color1 = 2 'white
Dim color2 As Integer
color2 = 15 'gray
Dim c As Integer
c = color1
Dim currid As String
currid = ""
Do While (Cells(i, 1) <> "")
If currid <> Cells(i, 1) Then
currid = Cells(i, 1)
If c = color1 Then
c = color2
Else
c = color1
End If
End If
Rows(Trim(Str(i)) + ":" + Trim(Str(i))).Interior.ColorIndex = c
i = i + 1
Loop
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment