Forum Discussion
Kay Fraone
Aug 07, 2017Copper Contributor
Alternating row colors
Hello all, I often use =Mod(row),2)-1 to apply alternating row colors, where the first row does not receive the formatting. I also have a simple macro that I use to run that type of conditional for...
- Aug 09, 2017
Something like this will work:
Sub Test() Dim myVar As Long myVar = ActiveCell.Row If myVar Mod 2 = 1 Then MsgBox "I'm an odd number!" Else MsgBox "I'm an even number" End If End Sub
Zack Barresse
Aug 30, 2017Iron Contributor
You can still use conditional formatting, no need for VBA, just adjust your formula. Something like this...
=MOD(ROW($A2)-ISEVEN(ROW(A$2)),2)
This assumes that your conditional formatting starts from A2 as the top-left cell in the applied range.