B
barberboy
Greeting Excel programmers. I have a simple question.
I have two macros that i use to add a conditional format to highlight
every other row for the cells that are selected. One macro gives the
EVEN rows (e.g. 2,4,6) a blue background and ODD (e.g. 1,3,5) rows a
white background. The other does the opposite: ODD rows blue, EVEN rows
odd. (The only thing different about them is the '=' vs the '>' in the
conditional formatting function.)
What i would like is a macro that will check to see if the FIRST row in
the selection is odd, and if it is, apply the EvenRowsBlue macro. If it
is even, apply the OddRowsBlue macro.
These are the two macros i have now, but if there is a different/better
way without them, i am up for that.
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
Thanks in advance!!
I have two macros that i use to add a conditional format to highlight
every other row for the cells that are selected. One macro gives the
EVEN rows (e.g. 2,4,6) a blue background and ODD (e.g. 1,3,5) rows a
white background. The other does the opposite: ODD rows blue, EVEN rows
odd. (The only thing different about them is the '=' vs the '>' in the
conditional formatting function.)
What i would like is a macro that will check to see if the FIRST row in
the selection is odd, and if it is, apply the EvenRowsBlue macro. If it
is even, apply the OddRowsBlue macro.
These are the two macros i have now, but if there is a different/better
way without them, i am up for that.
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
Thanks in advance!!