Hello here again.
I have this userform with multiple combo box
how can I remove Selected zone for any of the dropdown (column A and C combobox only)
example for this
I selected Zone 1 for the 1st combobox1, and zone2 for combobox2
zone 1 and 2 should not appear in combobox3.
zone 1 should also not appear in combobox2
as well as zone 2 should not appear in combobox 1
the combobox_change sub are repeated for all dependent combobox.
main ones are combobox , 1, 2, 3, 4, 5, 6, 7, and 15
ZONES2 is my named range for the list
I have this userform with multiple combo box
how can I remove Selected zone for any of the dropdown (column A and C combobox only)
example for this
I selected Zone 1 for the 1st combobox1, and zone2 for combobox2
zone 1 and 2 should not appear in combobox3.
zone 1 should also not appear in combobox2
as well as zone 2 should not appear in combobox 1
the combobox_change sub are repeated for all dependent combobox.
main ones are combobox , 1, 2, 3, 4, 5, 6, 7, and 15
ZONES2 is my named range for the list
VBA Code:
Private Sub UserForm_initialize()
Dim rng As Range
Dim ws As Worksheet
Set ws = Worksheets("ZONING")
For Each rng In ws.Range("ZONES2")
Me.ComboBox1.AddItem rng
Me.ComboBox2.AddItem rng
Me.ComboBox3.AddItem rng
Me.ComboBox4.AddItem rng
Me.ComboBox5.AddItem rng
Me.ComboBox6.AddItem rng
Me.ComboBox7.AddItem rng
Me.ComboBox15.AddItem rng
Next rng
Me.ComboBox2.Enabled = False
Me.ComboBox3.Enabled = False
Me.ComboBox4.Enabled = False
Me.ComboBox5.Enabled = False
Me.ComboBox6.Enabled = False
Me.ComboBox7.Enabled = False
Me.ComboBox8.Enabled = False
Me.ComboBox9.Enabled = False
Me.ComboBox10.Enabled = False
Me.ComboBox11.Enabled = False
Me.ComboBox12.Enabled = False
Me.ComboBox13.Enabled = False
Me.ComboBox14.Enabled = False
End Sub
Private Sub ComboBox1_Change()
Sheets("ZONING").Range("K37") = ComboBox1.Value
'Disable other drop down unless the previous have value
If ComboBox1.Value = "" Then
Me.ComboBox8.Enabled = False
Me.ComboBox2.Enabled = False
Me.ComboBox8.Value = ""
Me.ComboBox2.Value = ""
Else
Me.ComboBox8.Enabled = True
Me.ComboBox2.Enabled = True
End If
'Dependent list base on left dropdown
With Me.ComboBox8
Select Case ComboBox1.Value
Case Is = "ZONE1"
.RowSource = "ZONE1"
Case Is = "ZONE2"
.RowSource = "ZONE2"
Case Is = "ZONE3"
.RowSource = "ZONE3"
Case Is = "ZONE4"
.RowSource = "ZONE4"
Case Is = "ZONE5"
.RowSource = "ZONE5"
Case Is = "ZONE6"
.RowSource = "ZONE6"
Case Is = "ZONE7"
.RowSource = "ZONE7"
Case Is = "ZONE8"
.RowSource = "ZONE8"
End Select
End With
End Sub
Last edited: