Here's what I've added to your code
Code:
Private Sub ComboBox1_Change()
ComboBox2.Enabled = ComboBox1.Text <> ""
End Sub
Private Sub ComboBox2_Change()
ComboBox3.Enabled = ComboBox2.Text <> ""
End Sub
Private Sub ComboBox3_Change()
Dim lngCol As Long
With Worksheets("sample")
lngCol = .Rows(2).Find(What:=Me.ComboBox3.Text, lookAt:=xlWhole).Column
Me.ComboBox4.List = .Range("A4:A" & .Cells(.Rows.Count, lngCol).End(xlUp).Row).Offset(, lngCol - 1).Value2
Me.ComboBox5.List = .Range("A4:A" & .Cells(.Rows.Count, lngCol + 1).End(xlUp).Row).Offset(, lngCol).Value2
Me.ComboBox6.List = .Range("A4:A" & .Cells(.Rows.Count, lngCol + 2).End(xlUp).Row).Offset(, lngCol + 1).Value2
Me.ComboBox7.List = .Range("A4:A" & .Cells(.Rows.Count, lngCol).End(xlUp).Row).Offset(, lngCol - 1).Value2
Me.ComboBox8.List = .Range("A4:A" & .Cells(.Rows.Count, lngCol + 1).End(xlUp).Row).Offset(, lngCol).Value2
End With
Frame1.Enabled = UCase(ComboBox3.Text) = "INTERNAL"
Frame2.Enabled = Not Frame1.Enabled
ComboBox4.Text = ""
ComboBox5.Text = ""
ComboBox6.Text = ""
ComboBox7.Text = ""
ComboBox8.Text = ""
End Sub
In addition, I've also changed the style of your drop-down box to List-box instead of Combo-box. That way, user cannot 'type' anything that is not there in the list. In addition, I've also changed the Enabled property to false, and based on selection of value in the hierarchical order, the combo-boxes will get enabled.
Bookmarks