textbox character limits
One way... and I sure there is a more excel type way is
this will allow decimal point also
Private Sub textbox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If CheckBox2.Value = True Then
If KeyAscii 47 And KeyAscii < 58 Then ' 0 to 9
KeyAscii = KeyAscii
ElseIf KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 46 Then ' backspace
and enter keys
KeyAscii = KeyAscii
Else
KeyAscii = 0
End If
End If
End Sub
|