VBA Enable Disable ComboBox

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.
LVL 1
owntorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ComputronCommented:
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
Else
  ComboBox1.Enabled = False
  ComboBox2.Enabled = True
End if


There is also a visible property
ComboBox1.Visible = False
0
Ryan ChongCommented:
also can write like this:

combobox1.enabled = (ItemA = someValue)
combobox2.enabled = not combobox1.enabled
0
owntorAuthor Commented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ComputronCommented:
Private Sub ComboBox1_Click()
If ComboBox = "SomeValue" Then
  ComboBox1.Enabled = True
  ComboBox2.Enabled = False
Else
  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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
owntorAuthor Commented:
Would this only work for the controls ComboBox?  Just to clarify, I am using the forms ComboBox.
0
owntorAuthor Commented:
I would also like to gray-out the inactive comboboxes.
0
owntorAuthor Commented:
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...
0
owntorAuthor Commented:
Aha!  When I populated the comboboxes with data and the macro runs properly.

Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.