Breakdown hours worked

tezza

Active Member
Joined
Sep 10, 2006
Messages
375
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
  2. Web
Hi all,

Can anyone help automate the contents below please?

Col A & B are entered manually (well, copied from another data source) and the rest needs a formula/conditional formatting.

The idea is quite straight forward but I can't get excel to play ball.

If any of the hours from Col A and Col B are between 8pm and 9am then return how many hours are in that range, then the same for hours between 9am and 8pm. I think the biggest challenge would be row 6 so maybe only D6 and E6 needs to be correct and the rest would just follow.

The conditional format isn't so important but it would finish it off with a good visual :)

I've made a start with Col C

Book1
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACAD
1Start TimeEnd timeTotal TimeBetween 8pm and 9amBetween 9am and 8pm00:0001:0002:0003:0004:0005:0006:0007:0008:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:0021:0022:0023:00
206:0010:0004:0003:0001:00
318:0002:0008:0006:0002:00
411:0015:0004:0000:0004:00
523:0005:0006:0006:0000:00
618:0010:0016:0011:0005:00
7MANUAL ENTRYFORMULATED ENTRYCONDITIONAL FORMAT
Sheet1
Cell Formulas
RangeFormula
C2:C6C2=B2-A2+(B2<A2)


I've you take this on then I thank you very much in advance as I have roughly 1000 rows per week to calculate and it's taking a long time to do something I'm sure excel can do very quickly.

Tez
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
After a bit of research I think I've found a way to make it work, it might be crude but it's a start at least:

Timescales.xlsx
ABCDE
1Start TimeEnd timeTotal Time8am - 9pm9pm - 8am
206:0010:0004:001:003:00
318:0002:0008:002:006:00
400:0003:0003:000:003:00
508:0010:0002:001:001:00
620:0023:0003:000:003:00
711:0015:0004:004:000:00
823:0005:0006:000:006:00
918:0010:0016:003:0013:00
Sheet1 (2)
Cell Formulas
RangeFormula
C2:C9C2=MOD(B2-A2,1)
D2:D9D2=IF(A2<B2,MAX(0,MIN(B2,upper)-MAX(A2,lower)),MAX(0,upper-A2)+MAX(0,B2-lower))
E2:E9E2=C2-D2
Named Ranges
NameRefers ToCells
lower='Sheet1 (2)'!$AG$2D2:D9
upper='Sheet1 (2)'!$AG$3D2:D9

Timescales.xlsx
AFAG
1Time scale
2lower09:00
3upper20:00
Sheet1 (2)


00:0001:0002:0003:0004:0005:0006:0007:0008:0009:0010:0011:0012:0013:0014:0015:0016:0017:0018:0019:0020:0021:0022:0023:00


I couldn't put it side-by-side with this post due to an error message with Xl2bb on the following:

Conditional formatting G2:AD9
=AND($B2<$A2,$B2>G$1)
=AND(G$1>=$A2,OR(G$1<$B2+($B2<$A2),G$1<$B2))
 
Upvote 0
Solution

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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