Created
August 25, 2010 04:36
-
-
Save jsanti/548863 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' 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