Thursday, October 21, 2010

How can i set a VB form in Excel to allow only numbered characters to be entered in a text box?

I have a customer form I have created in VB in Excel. There are height and weight boxes and for validation I only want numbers to be entered, as you can do with validation in a database (subnet mask?). How can I build this into the code for my form in Excel?How can i set a VB form in Excel to allow only numbered characters to be entered in a text box?
If the text box is on a userform, you could use this event code.



Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)



If Chr(KeyAscii) Like ';[!0-9]'; Then KeyAscii = 0



End SubHow can i set a VB form in Excel to allow only numbered characters to be entered in a text box?
Have you tried validation?

No comments:

Post a Comment