Last active
November 9, 2015 02:59
-
-
Save misshie/730ea9e4c392fa608b4a to your computer and use it in GitHub Desktop.
An Excel VBA macro: Alterternate background of each row according to a key column (column C such as "chr1:123-123;A>T")
This file contains 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
Sub PhysPosGrouping() | |
Dim oRange As Range | |
Dim lRorB As Long | |
Dim lColR As Long | |
Dim gcount As Long | |
Set oRange = ActiveSheet.UsedRange | |
lRowB = oRange.Row + oRange.Rows.Count - 1 | |
lColR = oRange.Column + oRange.Columns.Count - 1 | |
For Each e In Range("C2:C" & lRowB) | |
If e <> e.Offset(-1, 0) Then | |
gcount = gcount + 1 | |
End If | |
If (gcount Mod 2) = 0 Then | |
e.EntireRow.Interior.ColorIndex = 15 | |
Else | |
e.EntireRow.Interior.ColorIndex = 0 | |
End If | |
Next e | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment