Compare Userform inputs

Joined
Aug 16, 2010
Messages
1
Reaction score
0
I need to compare two user inputs. If the second input is greater than the first, I want an error box to pop up and for it to clear out the input boxes forcing the user to input different values. This is the code I am trying to use right now. It's odd because if I input 10000 and 1000 in the boxes the code works, but if I input 10000 and 2000 it doesn't work. The error box pops up even though 2000 is not greater than 10000


Private Sub TextBox2_Change()
Dim answer As String

With TextBox2


If TextBox2.Value > TextBox1.Value Then

answer = MsgBox("The 2nd input can not be greater than the 1st input" & vbNewLine & "Please modify your input", vbOKOnly + vbCritical, "ERROR")
TextBox1.Value = ""
TextBox2.Value = ""
End If


End With
End Sub

thanks!!
CMS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top