Conditional formatting

Bob L

New Member
Joined
May 10, 2020
Messages
44
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a file that the first column are categories of food. Is it possible to have a formula in conditional formatting that alternates the color for every categories?

So cake and donut would be gray and pie and the next one after donut would remain white. The number of row per categories isn't fix as you can see.

Thanks in advance.

Cake
Cake
Cake
Cake
Cake
Pie
Pie
Pie
Donut
Donut
Donut
Donut
Donut
Donut
Donut
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
How about

+Fluff New.xlsm
A
1Food
2Cake
3Cake
4Cake
5Cake
6Cake
7Pie
8Pie
9Pie
10Donut
11Donut
12Donut
13Donut
14Donut
15Donut
16Donut
17
18
Main
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A16Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)textNO
 
Upvote 0
Ignore,
Did not see the previous reply

i can only see doing this with a helper column
Book1
ABCDEFGH
1
2Cake0
3Cake0
4Cake0
5Cake0
6Cake0
7Pie1
8Pie1
9Pie1
10Donut0
11Donut0
12Donut0
13Donut0
14Donut0
15Donut0
16Donut0
171
18
19
20
Sheet1
Cell Formulas
RangeFormula
D2:D17D2=MOD(IF(ROW()=2,0,IF(A2=A1,D1, D1+1)), 2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A:JExpression=$D1=1textNO
 
Upvote 0
Another helper-column option (helper column can be hidden) that keeps the formulas very simple is

Conditional Format in Groups.xlsm
IJ
1Food0
2Cake1
3Cake1
4Cake1
5Cake1
6Cake1
7Pie0
8Pie0
9Pie0
10Donut1
11Donut1
12Donut1
13Donut1
14Donut1
15Donut1
16Donut1
Cond Format In Groups
Cell Formulas
RangeFormula
J2:J16J2=IF(I2=I1,J1,1-J1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
I2:I16Expression=$J2textYES
 
Upvote 0
How about

+Fluff New.xlsm
A
1Food
2Cake
3Cake
4Cake
5Cake
6Cake
7Pie
8Pie
9Pie
10Donut
11Donut
12Donut
13Donut
14Donut
15Donut
16Donut
17
18
Main
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A16Expression=MOD(SUMPRODUCT(--($A$2:$A2<>$A$1:$A1)),2)textNO
This is perfect. Thank you!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

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