combobox control of other objects. problem when opening workbook

k9sar

New Member
Joined
Sep 9, 2014
Messages
1
Hi all, I have a problem that has be really tied around the axle. I have a worksheet(INTERFACE) that contains 3 comboboxes. Combobox1 is the main one that affects the entire sheet and what is being done. Based on certain values of combobox1, the other comboboxes become visible and usable. If combobox1 is set back to a default value of 0, I have the screen going back to nothing displayed (ie. combobox2 and 3 visibility = false). Everything works fine once the workbook is open but, during the opening process, it seems that all the subs for the comboboxes get triggered (I tried making it combobox1_click instead of _change and that did not help). One of the first checks in combobox1_click is to see if it's .value is 0. If so, set the visibility of combobox2 and 3 to false. The problem occurs during initialization of the workbook and I get an Object Required on the first ComboBox2.visible=false because the sheet does not yet recognize that there is a combobox2 yet (I found this by trying to type in me.comboBox... and it only had combobox1 as an available object). If I kill the vba from the popup error and let the workbook finish initializing, then go back into the exact same place in the combobox1_click code and try to put in me.combobox..., it shows all 3 as available objects. So my question is now, how do I either get the sub to recognize combobox2 and 3 OR keep the guts of the subs from running when I open the workbook?

Private Sub ComboBox1_Click()

Sheets("INTERFACE").Rows("9:60").Hidden = True
If ComboBox1.Value <> 0 Then
CommandButton1.Visible = True
Else
Sheets("Master").Range("A6") = 0 'set initial value in combobox2 linked cell
ComboBox2.Visible = False
Sheets("Sales").Range("A3") = 0 'set initial value in combobox3 linked cell
ComboBox3.Visible = False
CommandButton2.Visible = False
Exit Sub
End If
End If
... more stuff to do
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,191,191
Messages
5,985,209
Members
439,947
Latest member
fabiannic

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top