In Excel a User Form is created with some text boxes to input numeric data ONLY. How to I set this text box so that user is limited to key in the digits from 0 - 9. I would also like a pop up message to alert user if NOT a numeric key is pressed.
Many thanksIn Excel VB How to limit user to input numbers only in a text box?
This macro will validate Textbox1 as requiring numeric data entry. Change Textbox1 to the name of your textbox.
Place this code in the code section of your userform.
Private Sub TextBox1_Change()
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value %26lt;%26gt; ';'; Then
Me.Hide
MsgBox ';Entry must be numeric.';, vbOKOnly, ';Invalid Entry';
.Value = ';';
Me.Show
End If
End With
End SubIn Excel VB How to limit user to input numbers only in a text box?
click on the cell and Click on: Data %26gt; Validation %26gt; Whole Number %26gt; value Between 0-9, on the top of that little validation box, there is a tab with ';Error Alert'; edit that for the popup msg etc.
Hope that helps.
No comments:
Post a Comment