Dashboards
Power Pivot
June 25, 2016
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!
Power Query
Power Pivot
Xtreme Pivot Tables
Excel for Decision Making
Excel for Finance
Excel Analysis Toolpak
Power BI
Excel
Word
Outlook
Excel Expert
Excel Customer Service
November 8, 2013
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.
Dashboards
Power Pivot
June 25, 2016
VIP
Trusted Members
June 25, 2016
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
1 Guest(s)