Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default If-Then in ComboBox_Change..... (VB Code Newbie)

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
MDW MDW is offline
external usenet poster
 
Posts: 117
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox_Change Event to Populate another Combox Tobi Excel Programming 4 October 31st 06 11:34 PM
Weird Error with ComboBox_Change() Justin[_14_] Excel Programming 5 September 26th 06 07:41 PM
Combobox_change does not repond? Sige Excel Programming 8 October 14th 05 08:59 AM
Combobox_change event problem Shawn G.[_2_] Excel Programming 2 August 18th 05 01:37 PM
ComboBox_Change sub runs unexpectedly ChrisHouchin Excel Programming 0 May 25th 04 07:21 PM


All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"