TextBox That Allow only Number Format in Excel VBA

 Example for Data Validation : TextBox that allows only numeric keywords

Sometimes you need to enter valid information from the user through TextBoxes. In some cases If you need  only certain types of information like numeric or text. Then the best option is validation when user types the value in the entering field. So that you need to create a programm that accept only numeric or text. In this article I will show a textbox that will accept only numeric value



To get it, double click on the TextBox to write the following code

Private Sub TextBox1_Change()

If Me.TextBox1 = vbNullString Then Exit Sub

If Not IsNumeric(Me.TextBox1) Then

MsgBox "Sorry Mobilenumber in Numbers Only"

Me.TextBox1 = vbNullString

End If

End Sub

 


No comments:

Post a Comment