Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
Please consider this code:
The idea of this is to check to see whether t_time falls within a time range defined by variables ty9s and ty9e.
In the tests that are failing ....
t_time = 0.75 (6:00 PM)
ty9s = 0.6666666666666666667 (4:00 PM)
ty9e = 0 (12:00 AM)
In this example, 6:00 PM falls between 4:00 PM and midnight. However, it does not pass through as such. It gets trapped and the user message is displayed.
This code works in all other cases where ty9e isn't midnight, so I suspect this is the cause of the problem.
Is anyone able to suggest a solution to this problem?
Code:
t_base = ws_data.Range("W" & rn) ' "> 6:00 PM
l_len = Len(ws_data.Range("W" & rn)) ' 9
For x = 1 To l_len
If IsNumeric(Mid(t_base, x, 1)) Then Exit For
Next
t_time = TimeValue(Mid(t_base, x)) ' 0.75
t_crew_row = Application.WorksheetFunction.Match((cb_sig2_crew.Value & "1"), ws_staff.Range("I:I"), 0) ' 9
ty9s = CDate(WorksheetFunction.VLookup((Me.cb_sig2_crew.Value & "1"), ws_staff.Range("I5:M21"), 4, False))
ty9e = CDate(WorksheetFunction.VLookup((Me.cb_sig2_crew.Value & "1"), ws_staff.Range("I5:M21"), 5, False))
If t_time <= ty9s Or t_time >= ty9e Then 'CDate(Me.tb_sig_sttime.Value)
MsgBox cb_sig2_crew.Value & " is ineligible to provide this service.", vbInformation, "SERVICE NOTICE"
cb_sig2_crew.Value = ws_data.Range("X" & rn)
End If
The idea of this is to check to see whether t_time falls within a time range defined by variables ty9s and ty9e.
In the tests that are failing ....
t_time = 0.75 (6:00 PM)
ty9s = 0.6666666666666666667 (4:00 PM)
ty9e = 0 (12:00 AM)
In this example, 6:00 PM falls between 4:00 PM and midnight. However, it does not pass through as such. It gets trapped and the user message is displayed.
This code works in all other cases where ty9e isn't midnight, so I suspect this is the cause of the problem.
Is anyone able to suggest a solution to this problem?