View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
TommySzalapski[_9_] TommySzalapski[_9_] is offline
external usenet poster
 
Posts: 1
Default Disable/Prevent Letters or Numbers in textbox


Your tickets are the keypress event and the sendkeys method.
Use some code like:

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)

If Not (KeyAscii = 48 And KeyAscii <= 57) Then ' not a digit
Range("B17").Value = KeyAscii
SendKeys ("{BS}") 'send backspace
End If

End Sub

What it does is sends a backspace character immediately after any
non-digit character.


--
TommySzalapski
------------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...o&userid=25561
View this thread: http://www.excelforum.com/showthread...hreadid=390166