Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://www.mrexcel.com/board/threads/userform-combo-box-options-based-on-another-combo-box.578055/

Private Sub UserForm_Initialize()
    ComboBox1.AddItem "Grains"
    ComboBox1.AddItem "Fruits"
    ComboBox1.AddItem "Dairy"
End Sub

Private Sub ComboBox1_Change()
    Application.EnableEvents = False
    ComboBox2.Clear
    Application.EnableEvents = True
    
    Select Case ComboBox1.Value
        Case "Grains"
            ComboBox2.AddItem "Cereals"
            ComboBox2.AddItem "Breads"
            ComboBox2.AddItem "Pastsa"
        Case "Fruits"
            ComboBox2.AddItem "Apples"
            ComboBox2.AddItem "Oranges"
            ComboBox2.AddItem "Pears"
        Case "Dairy"
            ComboBox2.AddItem "Cheese"
            ComboBox2.AddItem "Milk"
            ComboBox2.AddItem "Yogurt"
    End Select
End Sub
  • No labels