Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,616
- Office Version
- 365
- 2016
- Platform
- Windows
I have this range of data...
This code
This code compares the end of shift times from column C of the data (ctime) to the service time (dtime). If the service time is later than the end of shift time , then clear cells B , C, E and put an X in D.
If I coded my logic correctly (and clearly I haven't because I'm not getting these preferred results) all rows with the exception of rows 19, 20, 21 (this one I expected to be problematic due to the end being at midnight), 25 and 26.
But, in my testing, everything was being cleared. Can someone help me figure out the error and avoid the potential midnight problem (I'm afraid it will think its midnight of that day and not the next)?
Any help would be greatly appreciated with this hurdle.
Excel Workbook | |||||||
---|---|---|---|---|---|---|---|
A | B | C | D | E | |||
16 | WP | * | * | * | * | ||
17 | CWP | 7:00 AM | 3:00 PM | 3 | 1 | ||
18 | WPE | 7:00 AM | 3:00 PM | B | 2 | ||
19 | CUE | 11:00 AM | 7:00 PM | 5 | 3 | ||
20 | WPL | 1:30 PM | 9:30 PM | A | 4 | ||
21 | CUL | 4:00 PM | 12:00 AM | 6 | 5 | ||
22 | CRP | 7:00 AM | 3:00 PM | 2 | 6 | ||
23 | HPE | 7:00 AM | 3:00 PM | B | 7 | ||
24 | RPE | 7:00 AM | 3:00 PM | B | 8 | ||
25 | HPL | 1:30 PM | 9:30 PM | A | 9 | ||
26 | RPL | 2:00 PM | 10:00 PM | A | 10 | ||
SBASE |
This code
Code:
For P = 17 To 26
If tpgo = "<" Then
ctime = ws_sbase.Cells(P, 2) 'end of shift (time)
dtime = dpgo 'service time
If Round(dtime, 5) >= Round(ctime, 5) Then 'eliminate all staff whose shift ends before the service time
ws_sbase.Range("B" & P & ":C" & P).ClearContents
ws_sbase.Range("D" & P) = "X"
ws_sbase.Range("E" & P) = ""
End If
End If
Next P
This code compares the end of shift times from column C of the data (ctime) to the service time (dtime). If the service time is later than the end of shift time , then clear cells B , C, E and put an X in D.
If I coded my logic correctly (and clearly I haven't because I'm not getting these preferred results) all rows with the exception of rows 19, 20, 21 (this one I expected to be problematic due to the end being at midnight), 25 and 26.
But, in my testing, everything was being cleared. Can someone help me figure out the error and avoid the potential midnight problem (I'm afraid it will think its midnight of that day and not the next)?
Any help would be greatly appreciated with this hurdle.