'How to Limit user to input Numeric number only in all Textbox/ TextBox having same name pattern in Excel userform
I have 60 Textbox in a Excel Userform. To limit user to input numeric number(Decimal) only for TextBox1 to TextBox50, I need to write lots of same code as below.
My question:
1.I want to create a class/function whatever as if I don't need to write same code for TextBox1 to TextBox50. Is there easy solution?
2.If i want to limit user for numeric number in All textbox of userform.
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii > 47 And KeyAscii < 58) Or KeyAscii = 46 Then
KeyAscii = KeyAscii
Else
KeyAscii = 0
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'same code
End Sub
.......
.......
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
