Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
This snippit of code checks to see if a time value (svc_off) falls with an employee's shift (crew_st and crew_et, representing the start and end times respectively as a number). From my testing thus far, things seem to be working as expected, but I run into a challenge when the shift is 4:00PM - midnight.
If svc_off = .75 (6:00PM), the if statement is false and the code doesn't run. I'm assuming its checking the range of .666667 (4:00P) and 0 (12:00A).
How can I overcome this? Again with the assuming, but I will likely need to add the date value to the time.
Would the best way to overcome this be to add the date value to each time and using an if then statement, add the date + 1 to the crew_et value if it is equal to zero? Sounds like it might work in this particular case, but what happens with other shifts that go into the next day?
Code:
If svc_off > crew_st And svc_off < crew_et Then 'can this crew's shift accomodate this service
temp_grm_cnt = temp_grm_cnt + 1
ws_thold.Cells(thold_dr, 10) = temp_grm
thold_dr = thold_dr + 1
End If
End If
If svc_off = .75 (6:00PM), the if statement is false and the code doesn't run. I'm assuming its checking the range of .666667 (4:00P) and 0 (12:00A).
How can I overcome this? Again with the assuming, but I will likely need to add the date value to the time.
Would the best way to overcome this be to add the date value to each time and using an if then statement, add the date + 1 to the crew_et value if it is equal to zero? Sounds like it might work in this particular case, but what happens with other shifts that go into the next day?