Formatting based on change in cell content

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
841
Office Version
  1. 365
I have a spreadsheet which runs a macro that dumps the required information from various worksheets into "sheet01"

it contains a list of employees, shift times & Reference numbers.
it is sorted by reference numbers.
im most instances there are duplicate reference numbers so the output is something like..

101212
101212
101212
232321
232321
989981
999999
999999

i would like of possible to be able to add to the end of the macro, a conditional formatting procedure which colours the sheet 01 row data either black or white wherever there is a change in the reference number column just to make it visually easier to the user

thanks in advance
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
If your data is in column A starting at a1 you can use the conditional formatting formula:

=MOD(COUNTIF(A$1:A1,A1),2)=0
 
Upvote 0
If your data is in column A starting at a1 you can use the conditional formatting formula:

=MOD(COUNTIF(A$1:A1,A1),2)=0

Thanks for the respose
its not quite doing what i need however (probably due to my poor explanation)
if i apply the formatting above it will highight the rows as follows as it changes based on whether the cells above is differennt of not.

103746 - highlight
111972 - highlight
114880 - highlight
114880 - does not highlight
114990 - highlight
115293 - highlight
115345 - does not highlight
115345 - highlight

what i need it to do however is

103746 - highlight
111972 - not highlight
114880 - highlight
114880 - highlight
114990 - not highlight
115293 - highlight
115345 - not highlight
115345 - not highlight

so that it visually flags up records with the same reference in them in the same colour

cheers
 
Upvote 0
This is what I got with my formula:

<TABLE style="WIDTH: 48pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=64 x:str><COLGROUP><COL style="WIDTH: 48pt" width=64><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; WIDTH: 48pt; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 width=64 align=right x:num>103746</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 align=right x:num>111972</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 align=right x:num>114880</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND: red; HEIGHT: 12.75pt; COLOR: windowtext; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0; mso-ignore: style; mso-pattern: auto none" class=xl22 height=17 align=right x:num>114880</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 align=right x:num>114990</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 align=right x:num>115293</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND-COLOR: transparent; HEIGHT: 12.75pt; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0" class=xl22 height=17 align=right x:num>115345</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #f0f0f0; BACKGROUND: red; HEIGHT: 12.75pt; COLOR: windowtext; BORDER-TOP: #f0f0f0; BORDER-RIGHT: #f0f0f0; mso-ignore: style; mso-pattern: auto none" class=xl22 height=17 align=right x:num>115345</TD></TR></TBODY></TABLE>

In your example why is 115345 not highlighted but 114880 is?
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

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