Hello,
I have 3 columns A,B,C and 3 combobox.
Data from Column A gets populated on 1st combobox, column B in 2nd and column C in 3rd.
Below is the code I came across that achieves this -
Option Explicit
Private Sub cbPrimary_Change()
Dim Name As String, R(), Counter As Integer, I As Integer
Name = cbPrimary.Value
For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
If Cells(Counter, 1).Value = Name Then
I = I + 1
ReDim Preserve R(I - 1)
R(I - 1) = Cells(Counter, 2).Value
End If
Next Counter
UFSelection.cmSecondary.List = R
End Sub
Private Sub UserForm_Initialize()
Dim Counter As Integer, R
With CreateObject("Scripting.Dictionary")
For Counter = 1 To Cells(Rows.Count, 1).End(xlUp).Row
.Item(Cells(Counter, 1).Value) = ""
Next Counter
R = .keys
End With
cbPrimary.List = R
End Sub
Private Sub cmSecondary_Change()
Dim Name As String, R(), Counter As Integer, I As Integer
Name = cmSecondary.Value
For Counter = 1 To Cells(Rows.Count, 2).End(xlUp).Row
If Cells(Counter, 2).Value = Name Then
I = I + 1
ReDim Preserve R(I - 1)
R(I - 1) = Cells(Counter, 3).Value
End If
Next Counter
UFSelection.ComboBox1.List = R
End Sub
I'm looking for a code that can auto populate 3rd combobox based on what is selected in the 2nd combobox.
Have attached sample sheet
Bookmarks