Conditional Formatting

D

DBavirsha

I am looking for a formula that I could add to conditional formatting to
highlight groups of rows EVERY OTHER time the value changes in a column, say
column C. In my example below if the following values are found in column C,
then the rows containing the 460 values, the 493 values and the 619 values
would all be highlighted, and the rows containing the 481 values and the 610
values would be unhighlighted. If conditional formatting is not the way to
go and I need to use code to accomplish this then I would like the help
writing the code.

Thanks for your help.

Col C
460
460
460
481
481
481
481
493
493
610
610
619
619
619
 
J

Joel

You have to do it with code


Sub switch_colors()
Const ColorRed = 3
Const ColorBlue = 5

RowCount = 1
Color1 = ColorRed
Color2 = ColorBlue
MyColor = Color1
Do While Range("C" & RowCount) <> ""
Range("C" & RowCount).Interior.ColorIndex = MyColor
If Range("C" & RowCount) <> Range("C" & (RowCount + 1)) Then
If MyColor = Color1 Then
MyColor = Color2
Else
MyColor = Color1
End If
End If
RowCount = RowCount + 1
Loop
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top