Hi Everyone,
I have a TEXT box which I put a query that it should not be less than or more than 10 characters. And if it is less than or more than, a message box will appear.
What I actually want is that the user will not able to proceed on the next Text Box.
What am I missing on my codes? please help me 
Thank you
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
If Len(UserForm2.TextBox1.Value) < 10 Then
MsgBox "Your Treaty Number is Incomplete, please correct!"
UserForm2.TextBox1.SetFocus
Else
If Len(UserForm2.TextBox1.Value) > 10 Then
TextBox1.Value = LEFT(TextBox1.Value, 5)
MsgBox "Your Treaty Number exceeded 10 Characters, please correct!"
UserForm2.TextBox1.SetFocus
End If
End If
End Sub
Bookmarks