If-Then in ComboBox_Change..... (VB Code Newbie)
I would suggest creating an outside procedure that does all your entry
verification, and then call it from each ComboBox_Change() event. That way
you're covered and you don't need to duplicate code.
Private Sub ComboBox1_Change()
Call do_verify
End Sub
Private Sub ComboBox2_Change()
Call do_verify
End Sub
Private Sub do_verify()
' In the future, you could expand this sub to do other things you may
' need to check, and both of your combobox_change events will work
' just fine.
If ComboBox1.Value < "" And ComboBox2.Value < "" Then
CommandButton1.Visible = True
End If
End Sub
--
Hmm...they have the Internet on COMPUTERS now!
"JustBreathe" wrote:
Below is is my code. Question is, how do I properly write my If-then
statement to check that both combobox1 AND combobox2 have a value selected
before the "Ok" button pops up?
whoa as I am typing this question I realize my second Private Sub is
specifically for ComboBox1....perhaps my problem?! but still way to green (ie
learning as I go) to know what to try next.
TIA!!!!!
Private Sub UserForm_Activate()
ComboBox1.AddItem "0 %"
ComboBox1.AddItem "25 %"
ComboBox1.AddItem "50 %"
ComboBox1.AddItem "95 %"
ComboBox1.AddItem "100 %"
ComboBox2.AddItem "No"
ComboBox2.AddItem "Yes"
End Sub
Private Sub ComboBox1_Change()
If ComboBox1.Value < "" Then CommandButton1.Visible = True
End Sub
|