I have created a userform with 3 dependent comboboxes and it works well. Can anyone please tell me how I can add another combobox (with items) within the same code, but is independent from the rest of the comboboxes. Here's the code I used. Thank you @DanteAmor for posting the code somewhere else. You spared me a lot of stress.
Excel Formula:
Option Explicit
Dim sh As Worksheet
Private Sub ComboBox1_Change()
Dim c As Range, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
ComboBox2.Clear
ComboBox3.Clear
For Each c In sh.Range("A2", sh.Range("A" & Rows.Count).End(xlUp))
If c.Value = ComboBox1.Value Then
dic(c.Offset(0, 1).Value) = Empty
End If
Next
ComboBox2.List = dic.keys
End Sub
Private Sub ComboBox2_Change()
Dim c As Range, dic As Object
ComboBox3.Clear
For Each c In sh.Range("A2", sh.Range("A" & Rows.Count).End(xlUp))
If c.Value = ComboBox1.Value And c.Offset(0, 1).Value = ComboBox2.Value Then
ComboBox3.AddItem c.Offset(, 2).Value
End If
Next
End Sub
Private Sub UserForm_Activate()
Dim c As Range, dic As Object
Set sh = Sheets("Database")
Set dic = CreateObject("Scripting.Dictionary")
For Each c In sh.Range("A2", sh.Range("A" & Rows.Count).End(xlUp))
dic(c.Value) = Empty
Next
ComboBox1.List = dic.keys
End Sub