Jun 13 2023 09:00 AM
Disclaimer: I'm a VBA noob, so I'm well aware that the solution to this issue is probably extremely simple.
I want to make a ListBox that populates dynamically based on what option the user selects in the ComboBox above it. I've attached an example to show how I'm currently trying to do it, but it won't compile and says that I haven't specified an object. What am I doing wrong?
Private Sub CategoryComboBox_Change()
OptionListBox.Clear
'determine options based on selected category
Dim selectedCategory As String
Set selectedCategory = CategoryComboBox.Value
Select Case selectedCategory
Case "Fruit"
OptionListBox.AddItem "Apple"
OptionListBox.AddItem "Orange"
OptionListBox.AddItem "Banana"
Case "Vegetable"
OptionListBox.AddItem "Broccoli"
OptionListBox.AddItem "Green Beans"
OptionListBox.AddItem "Carrots"
Case "Starch"
OptionListBox.AddItem "Mashed Potato"
OptionListBox.AddItem "Pasta"
OptionListBox.AddItem "Rice"
End Select
End Sub
Jun 13 2023 09:04 AM
Jun 13 2023 09:44 AM
Jun 13 2023 04:30 PM
Jun 14 2023 09:20 AM
@peiyezhu it's actually the line "Set selectedCategory = CategoryComboBox.Value
Jun 14 2023 04:34 PM