I missed the "digits" part of your question. My previous reply
restricts TextBox1 to 2 characters, not necessarily 2 digits. Use the
following instead. It limits input to 2 digits.
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(Me.TextBox1.Text) = 2 Then
KeyAscii = 0
Else
Select Case KeyAscii
Case vbKey0 To vbKey9
' OK
Case Else
KeyAscii = 0
End Select
End If
End Sub
Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
On Fri, 4 Sep 2009 06:56:02 -0700, Jock
wrote:
How do I limit TextBox data entry to 2 digits?
Short and sweet!