Lets say you have your data in sheet1:
1- You can use combobox_Change event handlers to track when the user has selected a new value from a combobox.
2- Combobox.listindex: This will give you the currently selected index in the combobox
3- Combobox.list: Is an array with all the items in the combo box
Private Sub ComboBox1_Change()
Dim strValue As String
Dim i As Integer
If ComboBox1.ListIndex <> -1 Then
strValue = ComboBox1.List(ComboBox1.ListIndex)
ComboBox2.Clear
ComboBox3.Clear
For i = 1 To 6
If Cells(i, 1) = strValue Then
If exists(ComboBox2, Cells(i, 2)) = False Then
ComboBox2.AddItem (Cells(i, 2))
End If
If exists(ComboBox3, Cells(i, 3)) = False Then
ComboBox3.AddItem (Cells(i, 3))
End If
End If
Next i
Else
ComboBox2.Clear
ComboBox3.Clear
End If
End Sub
Private Sub ComboBox2_Change()
Dim strValue1 As String
Dim strValue2 As String
Dim i As Integer
If (ComboBox2.ListIndex <> -1) And (ComboBox1.ListIndex <> -1) Then
strValue1 = ComboBox2.List(ComboBox2.ListIndex)
strValue2 = ComboBox1.List(ComboBox1.ListIndex)
ComboBox3.Clear
For i = 1 To 6
If (Cells(i, 2) = strValue1) And (Cells(i, 1) = strValue2) Then
If exists(ComboBox3, Cells(i, 3)) = False Then
ComboBox3.AddItem (Cells(i, 3))
End If
End If
Next i
Else
ComboBox3.Clear
End If
End Sub
Private Sub UserForm_Initialize()
Dim i As Integer
For i = 1 To 6
If exists(ComboBox1, Cells(i, 1)) = False Then
ComboBox1.AddItem (Cells(i, 1))
End If
Next i
End Sub
Private Function exists(ByRef objCmb As ComboBox, ByVal strValue As String) As Boolean
Dim i As Integer
For i = 1 To objCmb.ListCount
If strValue = objCmb.List(i - 1) Then
exists = True
Exit Function
End If
Next i
exists = False
End Function
The code will work assuming you have 3 combo boxes with the names Combobox1, Combobox2 and Combobox3 (the default names the VBA editor creates)