
Originally Posted by
barberboy@gmail.com
Sub OddRowsBlue()
'
' Created by barberboy, 18-12-05
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)>0"
.FormatConditions(1).Interior.ColorIndex = 34
.Interior.ColorIndex = 2
End With
End Sub
Sub EvenRowsBlue()
'
' Created by barberboy, 18-12-05
With Selection
.FormatConditions.Delete
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=0"
.FormatConditions(1).Interior.ColorIndex = 34
.Interior.ColorIndex = 2
End With
End Sub
Sub RowsBlue()
With Selection
.FormatConditions.Delete
If Selection.Cells(1,1).Row Mod 2 > 0 Then
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)>0"
Else
.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=0"
End If
.FormatConditions(1).Interior.ColorIndex = 34
.Interior.ColorIndex = 2
End With
End Sub
This should effectively always colour your first row blue, regardless if it's even or odd.
Bookmarks