How to restrict a VBA text box to accept letters only
I have textBox on a VBA form named txtAnswer
I would like to restrict what can be entered in a VBA TextBox (txtAnswer) to letters only.
If the user presses a number key the number will not be typed into the TextBox but instead a Message Box will pop up showing the number key that has been pressed. Also if the user presses the Enter Key a Message Box should pop up saying “You pressed Enter Key”
So if the user starts typing “ a p p p l e “ then the word “apple” will get typed into txtAnswer, but if the user presses a number key such 3 then the text in the txtAnswer will remain unchanged but a message box will pop saying “You pressed 3 ‘“
Thank you for your help.
Microsoft OfficeMicrosoft AccessVBAMicrosoft ExcelMicrosoft Word
Thank you all experts for taking the time to answer my questions. Both Neeraj’s and Roy’s solution were very helpful and therefore I am accepting both.
Subodh Tiwari (Neeraj)
You're welcome Faheem! Glad we could help.
Thanks for the feedback!