Macro to colour rows needed

chuckles1066

Banned
Joined
Dec 20, 2004
Messages
372
Hi all,

I've tried to adapt something that I picked up here previously but to no avail.

I'll keep it simple, I think I'll be able to modify whatever solutions you guys are able to come up with.

So.....column A contains date, column B contains time and column C contains site ID.

Starting at the first row of data (row 2) format the row from columns A to C with a colour (say purple).

Now the fun begins......

For each subsequent row, the macro should

(a) check to see if the site ID matches the one above
(b) if it does, is the time in that row less than 2 hours from the row above
(c) if so, then the row needs to be coloured as the row above
(d) if not, or if the site ID doesn't match the one above, the macro needs to do nothing, move onto the next row and repeat the procedure

Any advice greatly appreciated as always.

(PS: if anyone's feeling especially brave, at some future point I'll have to build in something to determine the 2 hour thing when the date is different; e.g 23.00 hours on a Friday to 00.05 hours on a Saturday is less than 2 hours but my existing macro won't pick it up because if you subtract 23.00 from 00.05 the maths doesn't work).
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Compare date plus time to get your maths working. You say that you have a macro already ... is it that you can't get it working properly? Maybe you could show your code if that is the case.
 
Upvote 0
I perhaps did not understand the full implications of your needs. can you work on this.

see the formula in the sample sheet in column D and its conditional foramtting

Excel Workbook
ABCD
1datetimeid
24/1/20117:00a
34/1/201110:00s0.13
44/1/201111:00d0.04
54/1/201123:30f0.52
64/2/20110:40g0.05
Sheet1


the conditional formatting is for D3 is
the formula is
=D3<=2/24
and this format is copied down the column D(pastepscial-format)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,712
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