I have a userform in which the user selects an individual's name from a combobox (ce_name), and then enters the start (ce_start) and end (ce_end) times in two proceeding textboxes. These two time values are checked then to see whether they are valid times. (custom function onExit)
Private Sub ce_start_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Not onExit(ce_start) Then
With ce_start
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Cancel = True
End If
Worksheets("Staff").Range("D4") = Format(ce_start.Value, "h:mm am/pm")
End Sub
The problem I'm having is bypassing the time validation check when the user selects "Not staffed" from the combobox. If the user selects "Not staffed", I have the time start and time stop defaulting to an "X". Well ... you can see the problem. Although I want an "X" in this scenario, the validation check disallows it.
Private Sub ce_name_change()
If Application.EnableEvents = False Then Exit Sub
If ce_name = "Not Staffed" Then
ce_start.Value = "X"
ce_end.Value = "X"
End If
ce_crewid.Value = WorksheetFunction.VLookup(ce_name, Worksheets("staff").Range("L4:M20"), 2, False)
Worksheets("Staff").Range("B4") = ce_name.Value
End Sub
What might you suggest I need to add to provide a bypass when ce_name = "Not staffed", or ce_start / ce_end equal "X"?
Thank you in advance.
Jenn
Bookmarks