• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Using VBA to define input

Hi,

I'm a VBA newbie.

I'm creating a form which includes % values and currency values

How do I insure that the user will only enter numeric values in each of these fields?

1st field must always be a %

2nd field must always be a currency amount


Thanks

Kevin
 
I don't think you can force currency or percentage however...


You could write vba code that triggers on change of the text box which checks if the entry is numeric and if not displays a warning message then clears the text box.


Then once the entry is numeric you can format the numeric value within your macro to whatever value you want.
 
Something like this

[pre]
Code:
Private Sub TextBox1_Change()
If Not IsNumeric(Me.TextBox1.Value) Then
MsgBox "your message here"
Exit Sub

End If
End Sub
[/pre]
 
Back
Top