I have a userform that includes 2 combo boxes (cboRoadway, cboStreet). These 2 are dependent on each other. It is comparable to a city / state drop down list.
By selecting roadway AA, you would get a list of matching cross streets for AA.
By selecting roadway BB, you would get a new list of matching cross streets for BB.
cboRoadway list values are populated in my userform_initialize statement.
Scenario: user selects a roadway, then selects a matching street. The user realizes they chose the wrong roadway, so they go back and change the roadway.
I need the street list to clear and refresh so that they new street choices match the new roadway selection.
I hope this makes sense. Go easy on me since I've only done a handful of my own VBA projects.
Private Sub cboRoadway_AfterUpdate()
Dim cStreeet As Range
Dim ws As Worksheet
Set ws = Worksheets("Data")
Select Case cboRoadway.Value
Case "AA"
For Each cStreet In ws.Range("e1:e19")
With Me.cboStreet
.AddItem cStreet.Value
.List(.ListCount - 1, 1) = cStreet.Offset(0, 1).Value
End With
Next cStreet
Case "BB"
For Each cStreet In ws.Range("f1:f15")
With Me.cboStreet
.AddItem cStreet.Value
.List(.ListCount - 1, 1) = cStreet.Offset(0, 1).Value
End With
Next cStreet
Case "CC"
For Each cStreet In ws.Range("g1:g18")
With Me.cboStreet
.AddItem cStreet.Value
.List(.ListCount - 1, 1) = cStreet.Offset(0, 1).Value
End With
Next cStreet
End Select
End Sub
Bookmarks