Conditional formatting

mpezz

New Member
Joined
Aug 6, 2010
Messages
3
Given a range in column (e.g. containing 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4) is there a way to use conditional formatting to alternate colors for the differenet groups of values (that is: 1s in red, 2s in black, 3s in red, etc.)?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Hi, welcome to the board.

I think it would be quite easy to use CF to make EVEN values black, and ODD numbers red.
Is this what you want ?
 
Upvote 0
Hi.
What I am looking for is a way to format the different groups, with alternate format. Data could be also text (e.g. a,a,a,a,x,x,x,y,y,y,y).
I would like to highlight blocks of contiguous data.
 
Upvote 0
OK. I'm not sure how to do that with standard CF.
You could use it to apply a colour based on whether the value in the current cell is the same as the one in the previous cell, but that's not quite what you're after.
It would give you something like this
A...black
A...red
A...red
B...black
C...black
C...red

See what I mean ?
Is that any use ?
 
Upvote 0
You can do this with two format contitions. Select A2 and set these formulas (and formats)

=MOD(SUMPRODUCT(--((INDEX($A:$A,1,1):INDEX($A:$A,ROW(A1),1))<>(INDEX($A:$A,2,1):INDEX($A:$A,ROW(A2),1)))),2)=0

and

=MOD(SUMPRODUCT(--((INDEX($A:$A,1,1):INDEX($A:$A,ROW(A1),1))<>(INDEX($A:$A,2,1):INDEX($A:$A,ROW(A2),1)))),2)=1

Format the colors appropriatly, these formula error in A1, so A1 should have a "natural" format the same as the =0 condition.
 
Upvote 0
Cleaner formula

=MOD(SUMPRODUCT(--($A$1:INDEX($A:$A,ROW(A1),1))<>($A$2:INDEX($A:$A,ROW(A2),1)))),2)=0
 
Upvote 0
You could select cell A2 and set these two CF formulas

Condition 1:
=(1=MOD(SUMPRODUCT(--($A$1:$A1<>$A$2:$A2)),2))

Condition 2:
=True

and copy the formatting to the other cells as needed.
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,981
Members
448,934
Latest member
audette89

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top