I'm trying to highlight a userform text box if the user types in an error. I've used txtbox1.setfocus and txtbox1.selstart and sellength but after the message comes up it goes to next field. Below are the codes:
Private Sub TxtTeenAge_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TxtTeenAge.Value = "" Then
ElseIf TxtTeenAge.Value < 7 Or TxtTeenAge.Value > 19 Then
TxtTeenAge.SelStart = 0
TxtTeenAge.SelLength = Len(TxtTeenAge.Text)
MsgBox ("less than or equal to 6")
End If
End Sub
Private Sub TxtTeenAge_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If TxtTeenAge.Value = "" Then
ElseIf TxtTeenAge.Value < 7 Or TxtTeenAge.Value > 19 Then
TxtTeenAge.SelStart = 0
TxtTeenAge.SelLength = Len(TxtTeenAge.Text)
MsgBox ("less than or equal to 6")
End If
End Sub