Timesheet - Sumproduct, ignoring text and auto calculating lunch time

MrAdelphi02

New Member
Joined
Jan 29, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have been racking my brain trying to come up with a solution to this but to no avail, so hopefully someone here can help me out.

OpenCloseOpenCloseOpenClose
8:00 AM4:00 PM6:00 PM12:30 AMTime Off

So the current formulas I have created are:

Formula 1:
=24*SUMPRODUCT(MOD(COLUMN(A2:F2),2)*(B2:F2-A2:E2+(B2:F2<A2:E2)-((B2:F2-A2:C2+(B2:F2<A2:C2))>=6.5/24)*0.5/24)))

This formula calculates the time worked and reduces by 30 mins if they work longer than 6.5 hours. It also takes into account anyone to works past midnight. But it does not work if non-text is used.

Formula 2:
=24*SUMPRODUCT(--(MOD(COLUMN(A2:F2)-COLUMN(A2)+1,2)=0)-(MOD(COLUMN(A2:F2)-COLUMN(A2)+1,2)=1),A2:F2)

This formula calculates the time worked and takes into account anyone who works past midnight and works if non-text is used, but I cannot make it reduce the time by 30 mins if they work longer than 6.5 hours in a day.

Can anyone help?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
HI,

Welcome to the Board!

You are using SUMPRODUCT - does it mean that the row can be arbitrarily long, with very many OPEN-CLOSE pairs?
Or is it like in your example, with 3 pairs and that's it?
In the latter case, a long by simple formula
=IFERROR(IF(D2<C2,D2+1-C2,D2-C2),0)+IFERROR(IF(B2<A2,B2+1-A2,B2-A2),0)+IFERROR(IF(F2<E2,F2+1-E2,F2-E2),0)-IF(IFERROR(IF(D2<C2,D2+1-C2,D2-C2),0)+IFERROR(IF(B2<A2,B2+1-A2,B2-A2),0)+IFERROR(IF(F2<E2,F2+1-E2,F2-E2),0)>6.5/24,0.5/24,0)
seems to do the job.

J.Ty.
 
Upvote 0
Thank you for your reply. The above example is only for 3 pairs, but I am looking for a formula that works for 7 pairs (7 days).

Adelphi
 
Upvote 0
OK, I will prepare something for the larger case, but only much later today.

J.Ty.
 
Upvote 0
Does this rule reduces by 30 mins if they work longer than 6.5 hours apply to each day separately, or to their sum?

J.Ty.
 
Upvote 0
I did a formula which assumes that the lunch rule applies to each day separately. Should work for any number of days. Please test it carefully.
=SUMPRODUCT(IFERROR((B1:F1)-(A1:E1)+((B1:F1)<(A1:E1))-(((B1:F1)-(A1:E1)+((B1:F1)<(A1:E1)))>(6.5/24))*(0.5/24),0)*(MOD(COLUMN(B1:F1),2)=0))
 
Upvote 0
I did a formula which assumes that the lunch rule applies to each day separately. Should work for any number of days. Please test it carefully.
=SUMPRODUCT(IFERROR((B1:F1)-(A1:E1)+((B1:F1)<(A1:E1))-(((B1:F1)-(A1:E1)+((B1:F1)<(A1:E1)))>(6.5/24))*(0.5/24),0)*(MOD(COLUMN(B1:F1),2)=0))

You genius!!!

that worked perfectly!!!!!!!!

Thank you so much.
 
Upvote 0
Thanks for the feedback and good luck!

J.Ty.
 
Upvote 0

Forum statistics

Threads
1,215,650
Messages
6,126,016
Members
449,280
Latest member
Miahr

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