Code to change cell colour

Damo10

Active Member
Joined
Dec 13, 2010
Messages
460
Hi,

I would like some code that will change the cell colour for all the cells in columns U:AK as long as the machine number in column U is the same.

The data is sorted by machine number in column U but the number of rows for each machine number will change daily sometimes it may be 1 row or as many as 20, what i would lke is to have 2 colours so it is easy to tell apart the different machines

See example below

Excel Workbook
U
45
55
65
75
85
923
1023
1123
1223
1323
1433
1533
1633
1733
Data
Excel 2010
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Hi,

You can do that with two Conditional Formatting Rules...
Excel Workbook
U
3
45
55
65
75
85
923
1023
1123
1223
1323
1433
1533
1633
17
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
U41. / Formula is =MOD(SUM(IF(U$4:U4<>U$3:U3,1,0)),2)=0Abc
U42. / Formula is =MOD(SUM(IF(U$4:U4<>U$3:U3,1,0)),2)<>0Abc
 
Upvote 0
Given that Conditional Formatting is volatile you could cut down the amount of processing overhead as follows ..

1. Colour all the rows manually one of the colours (I used the blue colour)
2. Use a helper column. Enter the formula shown and copy down. (You could then hide this column)
3. Select U4:AK? and apply the CF shown.

Excel Workbook
UVWXYZAAABACADAEAFAGAHAIAJAKAL
3
451
551
651
751
851
9230
10230
11230
12230
13230
14331
15331
16331
17331
CF Groups
Cells with Conditional Formatting
CellConditionCell FormatStop If True
U41. / Formula is =$AL4Abc
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,949
Latest member
Dupuhini

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