I have created a userform in Excel with several text boxes. In essence, I am trying to validate a user's input.
In this specific example, the user should enter a 10 digit phone number as ten digits (i.e. no dashes, etc.) If the user does not enter the data correctly, I would like the user to receive a message and then for the focus to be returned to the textbox.
All is working well EXCEPT the focus does not return to the textbox. I am using the before update event. I have also experimenting with placing the code in the after update event and the exit event but no luck. Any help would be appreciated. The code I am using is as follows:
Private Sub txtMIN_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If txtMIN.TextLength <> 10 Then
MsgBox ("Please enter a 10 digit MIN without dashes or other characters.")
Cancel = True
I will also add additional validation to ensure the data is all numberic after the above is working.