excel VBA

willeng

New Member
Joined
Jan 16, 2019
Messages
3
Hello guys

I am working on a break schedule for work and I am have a hard time with it I need to take the employee start work time add 2 hours for their first break 4 hours for their lunch and 6 hours for their last break.

also I need it to look to see if there is anyone else on break at that time if so add 15 mins to break time and recheck if not that would be the time the Employee is to go to break

same thing to Lunch time but in stead of 15mins it would 30mins

Thank you for any help anyone can help me with, I have been trying to work this out for over a month

Thanks
Willeng
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi Willeng, so these people work 12 hours a day? That is terrible! How long are breaks? Do workers start a the same time?
Sergio
 
Last edited:
Upvote 0
In Excel you can calculate 2/4/6 hours from start date easily, but how that interacts with actual time in/out and jobs worked is an entirely different question.
Here's an example of calculating 2/4/6 hours from start time:
StartBreak1LunchBreak2B2 CalcC2 CalcD2 Calc
8:0010:0012:0014:00=A2 + (2/24)=A2 + (4/24)=A2 + (6/24)

<tbody>
</tbody>
 
Upvote 0
Yes got that, to know if they are having a break together I need the spam of the break, how long is the break: 15, 20 minutes, and the lunch break?
This is what I got so far

W115W230W315
WorkerTime21st Brk St1st Brk End4Lunch Brk StLunch Brk End6Last Brk StLast Br EndTGTH
110:1512:1512:3016:3017:0023:0023:151
211:1513:1513:3017:3018:000:000:150
310:2012:2012:3516:3517:0523:0523:201
48:3010:3010:4514:4515:1521:1521:300
56:408:408:5512:5513:2519:2519:400
64:506:507:0511:0511:3517:3517:500

<tbody>
</tbody>
The column TGTH will te me to extend the break 15 more minutes

Cheers
Sergio
 
Upvote 0
Wait a minute, all entry times are rounded to the Hour? 08:00, 09:00 10:00 that way is so much easier!
Sergio
 
Upvote 0
The employees work 8 hours day breaks are 15 mins lunch is 30 mins and the employees start different times Example Emp1 starts at 9am, emp2 starts 10 so on
 
Upvote 0
Breaks are 15 mins,lunch is 30 mins
I have some employees that start at the same time and don’t want them to go to break or lunch at the same time.
Example:
Emp1
starts at 9am
first break 11am,
lunch 1pm,
last break 3pm
end shift at 5pm

Emp2
starts at 9am
first break 11:15am,
lunch 1:30pm due to Emp1 at break at 1pm
last break 3:15pm
end shift 5pm

Emp3
starts at 9:30am
first break 11:30,
lunch cant be at 1:30 due to emp2 would be on lunch so emp3 will go at 2pm,
last break 3:30
end shift 5:30pm

This is want I’m looking for excel to do for me
 
Upvote 0
Hi Willeng,
Now I get it! 2, 4 and 6 are the number of hours from entering time, good! I am relieved!
Here is what I got, my approach is to find "Shifts" in every time slot, so first worker entering at 09:00 gets slot 0, and second entering 09:00 get slot 1, and so on, see column Shift in time slot, from there on is pretty straightforward.

Breaks1st152nd303rd15
Worker
Time
Enters
Shift in
Time slot
21st Brk St1st Brk End2Lunch Brk StLunch Brk End2Last Brk StLast Br EndLeave
16:0008:008:1510:0010:3012:0012:1514:00
26:3008:308:4510:3011:0012:3012:4514:30
37:0009:009:1511:0011:3013:0013:1515:00
47:3009:309:4511:3012:0013:3013:4515:30
58:00010:0010:1512:0012:3014:0014:1516:00
68:30010:3010:4512:3013:0014:3014:4516:30
79:00011:0011:1513:0013:3015:0015:1517:00
89:30011:3011:4513:3014:0015:3015:4517:30
910:00012:0012:1514:0014:3016:0016:1518:00
1010:30012:3012:4514:3015:0016:3016:4518:30
1111:00013:0013:1515:0015:3017:0017:1519:00
1211:30013:3013:4515:3016:0017:3017:4519:30
136:0018:158:3010:3011:0012:1512:3014:00
146:3018:459:0011:0011:3012:4513:0014:30
157:0019:159:3011:3012:0013:1513:3015:00
167:3019:4510:0012:0012:3013:4514:0015:30
178:00110:1510:3012:3013:0014:1514:3016:00
188:30110:4511:0013:0013:3014:4515:0016:30
199:00111:1511:3013:3014:0015:1515:3017:00
209:30111:4512:0014:0014:3015:4516:0017:30
218:00210:3010:4513:0013:3014:3014:4516:00
228:30211:0011:1513:3014:0015:0015:1516:30
239:00211:3011:4514:0014:3015:3015:4517:00
249:30212:0012:1514:3015:0016:0016:1517:30

<tbody>
</tbody>
The formulas are below, first row of data worker 1 is row 3, last row of data worker 24 is row 26
Code:
C3 =COUNTIF([COLOR=#5F8CED]$B$2:B3[/COLOR],[COLOR=#EB5E60]B3[/COLOR])-1
E3 =[COLOR=#5F8CED]B3[/COLOR]+([COLOR=#EB5E60]$D$2[/COLOR]/24)+([COLOR=#8D61C2]C3[/COLOR]*[COLOR=#2D9639]$E$1[/COLOR]/(24*60))
F3 =[COLOR=#5F8CED]E3[/COLOR]+([COLOR=#EB5E60]E$1[/COLOR]/(60*24))
H3 =[COLOR=#5F8CED]B3[/COLOR]+(([COLOR=#EB5E60]$D$2[/COLOR]+[COLOR=#8D61C2]$G$2[/COLOR])/24+([COLOR=#2D9639]C3[/COLOR]*[COLOR=#BF4C91]$H$1[/COLOR]/(24*60)))
I3 =[COLOR=#5F8CED]H3[/COLOR]+([COLOR=#EB5E60]H$1[/COLOR]/(60*24))
K3 =[COLOR=#5F8CED]B3[/COLOR]+(([COLOR=#EB5E60]$G$2[/COLOR]+[COLOR=#8D61C2]$J$2[/COLOR]+[COLOR=#2D9639]$D$2[/COLOR])/24+([COLOR=#BF4C91]C3[/COLOR]*[COLOR=#E38222]$K$1[/COLOR]/(24*60)))
L3 =[COLOR=#5F8CED]K3[/COLOR]+([COLOR=#EB5E60]K$1[/COLOR]/(60*24))
M3 =[COLOR=#5F8CED]B3[/COLOR]+(8/24)

I hope this is what you were looking for
Cheers
Sergio
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,311
Members
449,080
Latest member
jmsotelo

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