I have created a UserForm to insert data into a table. One of the columns is for a phone number, so I have used the phone number special formatting on the worksheet to add in the parenthesis and dash. Is there a way in the VBA code for my UserForm to remove any dashes or parenthesis a user may have added when they type in the phone number? Currently on the UserForm I just have a text box to capture the information.
Thank you!
You can try a fairly simple code that will prevent users from typing wrong values in real time. There are some examples on this page, with date formats and numeric values between a specific range, but the code can be easily adapted to any format you want. Here is a link: excel-user-form-assistant
Works for Mac also.
Thank you, that was helpful information.
This is one I frequently use. It allows only numbers and nothing else (not even a space) to be entered into TextBox1.
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'Allow only numbers to be entered
Select Case KeyAscii
Case Asc("0") To Asc("9")
Case Else
KeyAscii = 0
End Select
End Sub