Deleting Comboboxes

A

aqualibra

I have two sets of comboboxes.
I set has 5 comboboxes and the other has 7 comboboxes.

In the second set, first five comboboxes are the same as set 1.

If I choose set1, all the comboboxes of set 1 are seen and if I choose set
2, all the comboboxes of set 2 are seen.

Is there a way to code such that depending on what set I choose their
respective comboboxes appear. In other words, I want the two extra comboboxes
to appear and disappear depending on what set is chosen.

Thanks you
 
F

FunkySquid

If you create 7 comboboxes and call then ComboBox1-7. Then create 2
OptionButtons and call them optSet1 and optSet2 then paste the
following code into the form.

Private Sub optSet1_Click()
If optSet1.Value = True Then
Call ChangeComboSet1Visible(True)
Call ChangeComboSet2Visible(False)
End If
End Sub

Private Sub optSet2_Click()
If optSet2.Value = True Then
Call ChangeComboSet1Visible(True)
Call ChangeComboSet2Visible(True)
End If
End Sub

Function ChangeComboSet1Visible(boolVisible As Boolean)
Me.ComboBox1.Visible = boolVisible
Me.ComboBox2.Visible = boolVisible
Me.ComboBox3.Visible = boolVisible
Me.ComboBox4.Visible = boolVisible
Me.ComboBox5.Visible = boolVisible
End Function

Function ChangeComboSet2Visible(boolVisible As Boolean)
Me.ComboBox6.Visible = boolVisible
Me.ComboBox7.Visible = boolVisible
End Function

Private Sub UserForm_Activate()
Call ChangeComboSet1Visible(False)
Call ChangeComboSet2Visible(False)
End Sub

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top