So, I have titles from from B1-M1 and row descriptions from A2-A41. I want to color every other row (B3:M3, B5:M5, B7:M7, ect..) gray.
I applied conditional formatting "=MOD(ROW(),2)=1" and ran a macro, but for some reason It's coloring in cells A3:M3, A5:M5, ect a color that isn't gray!
Here's the macro I recorded if someone could trouble shoot where I went wrong.
Sub CFAlternateRows()
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Cells.FormatConditions.Delete
Range("A2:M41").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 969696
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub CFAlternateRows_Cleaned()
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
With Range("A2:M" & lr)
.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)=1"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 969696
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
End Sub
Thanks a lot
I applied conditional formatting "=MOD(ROW(),2)=1" and ran a macro, but for some reason It's coloring in cells A3:M3, A5:M5, ect a color that isn't gray!
Here's the macro I recorded if someone could trouble shoot where I went wrong.
Sub CFAlternateRows()
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Cells.FormatConditions.Delete
Range("A2:M41").Select
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=1"
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 969696
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = False
End Sub
Sub CFAlternateRows_Cleaned()
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
With Range("A2:M" & lr)
.FormatConditions.Add Type:=xlExpression, Formula1:="=MOD(ROW(),2)=1"
.FormatConditions(.FormatConditions.Count).SetFirstPriority
With .FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 969696
.TintAndShade = 0
End With
.FormatConditions(1).StopIfTrue = False
End With
End Sub
Thanks a lot