Skip to content

Instantly share code, notes, and snippets.

@jsanti
Created August 25, 2010 04:36
Show Gist options
  • Select an option

  • Save jsanti/548863 to your computer and use it in GitHub Desktop.

Select an option

Save jsanti/548863 to your computer and use it in GitHub Desktop.

Revisions

  1. jsanti renamed this gist Sep 2, 2010. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. jsanti created this gist Aug 25, 2010.
    30 changes: 30 additions & 0 deletions *scratch*
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    ' 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