remove selected item for the next drop down

GeneBF

New Member
Joined
Jun 28, 2022
Messages
35
Office Version
  1. 365
Platform
  1. Windows
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
1658717518981.png


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:
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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
Back
Top