userform textbox, restricting special character entry

  • Re: userform textbox, restricting special character entry


    Try pasting this into the code of the userform. Obviously, this only works for "textbox1"


    Code
    Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)Select Case KeyAscii
        Case Asc("0") To Asc("9")
        Case Asc("A") To Asc("Z")
        Case Asc("a") To Asc("z")
        Case Else
            KeyAscii = 0
    End Select
    End Sub
  • Re: userform textbox, restricting special character entry


    Yes, I got the case asc ("a") to asc ("z") to work finally. When I posted this it was not working for some odd reason but now it is but thank you for the quick response! It is exactly what I have written.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!