Hy,
I have this code which works fine when you manualy type the information allowing only numbers. If I use the paste function in the textbox("DN") userform I can enter everything, letters ... . The code bellow is set to KeyPress, is it possibile to verify the textbox when I click a button or on the exit from the textbox? I am new to VBA and try to learn as i go, the code underneath is from the web. I have another code from the web which has enabled copy/paste function in my file.
Thanks,
Chris
I have this code which works fine when you manualy type the information allowing only numbers. If I use the paste function in the textbox("DN") userform I can enter everything, letters ... . The code bellow is set to KeyPress, is it possibile to verify the textbox when I click a button or on the exit from the textbox? I am new to VBA and try to learn as i go, the code underneath is from the web. I have another code from the web which has enabled copy/paste function in my file.
Code:
Private Sub DN_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii > 47 And KeyAscii < 58) Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
MsgBox ("ERROR")
End If
End Sub
Thanks,
Chris