I have a sheet with multiple activex comboboxes, some which are dependent on others. I have entered the following code to make those dependent comboboxes work, which is working fine for me.
Private Sub cboLocation_Change()
Me.cboCity_St.Clear
Dim ListCell1 As Range
For Each ListCell1 In Range(Me.cboLocation.List(Me.cboLocation.ListIndex))
Me.cboCity_St.AddItem (ListCell1.Value)
Next ListCell1
End Sub
Private Sub cboModule_Change()
Me.cboIssue.Clear
Dim ListCell2 As Range
For Each ListCell2 In Range(Me.cboModule.List(Me.cboModule.ListIndex))
Me.cboIssue.AddItem (ListCell2.Value)
Next ListCell2
End Sub
Also, I would like to add a button that would clear or reset this form. Which I have the following code for that, which did work until I added the previous code to make the dependent comboboxes work.
Sub mcrClear()
ActiveSheet.Shapes("cboIssue").OLEFormat.Object.Object.Value = ""
ActiveSheet.Shapes("cboModule").OLEFormat.Object.Object.Value = ""
ActiveSheet.Shapes("cboCity_St").OLEFormat.Object.Object.Value = ""
ActiveSheet.Shapes("cboLocation").OLEFormat.Object.Object.Value = ""
ActiveSheet.Shapes("cboUser").OLEFormat.Object.Object.Value = ""
End Sub
I receive a run-time error 381:
Could not get the List property. Invalid property array index.
RunTime381.png
VBA error.png
Bookmarks