Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,665
- Office Version
- 365
- 2016
- Platform
- Windows
I have this snippit of code
I am running into a issue with differences in times that cross over into the next day.
For example,
stv = 4:00 PM
edv = 0:00 AM
With this example, the code in blue will trigger as stv (start time) is greater than edv (end time), which yes is true, but not in this case. The shift is 8 hours from 4:00pm and carries into the next day. The code shouldn't trigger in this instance.
The value of edv is taken from a cell in the worksheet that has a formula of "=($J$11-$I$11+IF($J$11<$I$11,1,0))*24" which assists with user data entry error checking on the worksheet .
How can I overcome this while avoiding having to rewrite my code up to this point?
Rich (BB code):
With ws_dsched
.Unprotect
For i = 6 To 47
If IsNumeric(Left(.Cells(i, 8), 3)) Then
sw = sw + 1
stv = .Cells(i, 9)
edv = .Cells(i, 10)
If Not IsNumeric(stv) Then
.Cells(i, 9).Interior.Color = RGB(255, 0, 0)
ers = ers + 1
End If
If Not IsNumeric(edv) Then
.Cells(i, 10).Interior.Color = RGB(255, 0, 0)
ers = ers + 1
End If
If stv >= edv Then
.Cells(i, 9).Interior.Color = RGB(255, 0, 0)
ers = ers + 1
End If
Stop
td = (edv - stv) * 24
If td <> .Cells(i, 11) Then
.Cells(i, 11).Interior.Color = RGB(255, 0, 0)
ers = ers + 1
End If
Else
snw = snw + 1
'MsgBox "This is NOT a number."
End If
Next i
If ers > 0 Then
MsgBox "Please correct the highlighted errors."
Exit Sub
End If
End With
I am running into a issue with differences in times that cross over into the next day.
For example,
stv = 4:00 PM
edv = 0:00 AM
With this example, the code in blue will trigger as stv (start time) is greater than edv (end time), which yes is true, but not in this case. The shift is 8 hours from 4:00pm and carries into the next day. The code shouldn't trigger in this instance.
The value of edv is taken from a cell in the worksheet that has a formula of "=($J$11-$I$11+IF($J$11<$I$11,1,0))*24" which assists with user data entry error checking on the worksheet .
How can I overcome this while avoiding having to rewrite my code up to this point?