We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


VBA Enable Disable ComboBox

owntor asked
Medium Priority
Last Modified: 2013-12-25
I would like to enable and disable ComboBox selection in my Excel workbook.  

There are three ComboBoxes.  The user will make a choice of two items in an initial ComboBox.  If item A is selected then ComboBox A is enabled and ComboBox B is disabled.  If item B is selected then ComboBox B is enabled and ComboBox A is disabled.

Is there code such as:

ComboBox.Enabled = true

I want the initial ComboBox to fire a macro to enable and disable ComboBoxes A and B.
Watch Question

In the click event of the combobox, place the code to enable or disable the other 2 combo boxes just like you have above.

If ComboBox = SomeValue Then
  ComboBox1.Enabled = True
  ComboBox2.Enabled = False
  ComboBox1.Enabled = False
  ComboBox2.Enabled = True
End if

There is also a visible property
ComboBox1.Visible = False
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer

also can write like this:

combobox1.enabled = (ItemA = someValue)
combobox2.enabled = not combobox1.enabled


Will have to find the click event...  should it be some thing like this?

Private Sub ButtonClickEvent_Click(ByVal Ctrl As Office.CommandBarButton, _
    Set ButtonClickEvent = btn
    If Not btn Is Nothing Then
        MsgBox "Synced '" & btn.Caption & "' button events."
    End If
End Sub

and I'll rework in the combobox.enabled line into that sort of subroutine...

I will try it this morning.
Private Sub ComboBox1_Click()
If ComboBox = "SomeValue" Then
  ComboBox1.Enabled = True
  ComboBox2.Enabled = False
  ComboBox1.Enabled = False
  ComboBox2.Enabled = True
End if
End Sub

If you double click the combobox, it should take you to the code view, then switch from change event to click event

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Would this only work for the controls ComboBox?  Just to clarify, I am using the forms ComboBox.


I would also like to gray-out the inactive comboboxes.


When I apply this code to the forms comboboxes this error is thrown:  "Object Required."

So I tested this on a couple control comboboxes and it seems to work.

Will test some more...  Still trying to make this work with forms comboboxes...


Aha!  When I populated the comboboxes with data and the macro runs properly.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.