Hi,

I am a newbie to VBA.

I am trying to create dependant dropdown lists based on four different fields.
and am currently trying to make it so that I can have a list of options in one drop down list, and depending on what gets picked there, make it so that the
options for the second drop down list correspond with the first. I found vb code (by Matt) on one of the forums but couldn't make it work.

The screen shot of the excel file and the code are attached. I know it is full of mistakes. Hope someone can help me.


PHP Code: 
Private Sub CommandButton1_Click()
Dim myLastRow As Integer

Application
.ScreenUpdating False

Range
("A2").Select
Selection
.Sort Key1:=Range("A2"), Order1:=xlAscendingHeader:=xlYes_
    OrderCustom
:=1MatchCase:=FalseOrientation:=xlTopToBottom

ComboBox1
.Clear
ComboBox2
.Clear
myLastRow 
Range("a65000").End(xlUp).Row
Range
("A2").Select

Do Until ActiveCell.Row myLastRow
    
If ActiveCell.Value <> ActiveCell.Offset(-10).Value Then
        ComboBox1
.AddItem ActiveCell.Value
    End 
If
    
ActiveCell.Offset(10).Select
Loop
Application
.ScreenUpdating False

End Sub

Private Sub ComboBox1_Change()
Dim myLastRow As Integer

Application
.ScreenUpdating False

Range
("A2").Select
Selection
.Sort Key1:=Range("A2"), Key2:=Range("B2"), Order1:=xlAscendingOrder2:=xlAscendingHeader:=xlYes
ComboBox2
.Clear
myLastRow 
Range("a65000").End(xlUp).Row
Range
("A2").Select
Do Until ActiveCell.Value ComboBox1.Value
    ActiveCell
.Offset(10).Select
Loop

Do Until ActiveCell.Value <> ComboBox1.Value
    
If ActiveCell.Offset(01).Value <> ActiveCell.Offset(-11).Value _
        
Or ActiveCell.Offset(00).Value <> ActiveCell.Offset(-10).Value Then
        ComboBox2
.AddItem ActiveCell.Offset(01).Value
    End 
If
    
ActiveCell.Offset(10).Select
Loop
Application
.ScreenUpdating False


End Sub
Private Sub ComboBox2_Change()
Dim myLastRow As Integer

Application
.ScreenUpdating False

Range
("A2").Select
Selection
.Sort Key1:=Range("A2"), Key2:=Range("B2"), Key3:=Range("C2"), Order1:=xlAscendingOrder2:=xlAscendingHeader:=xlYes
ComboBox3
.Clear
myLastRow 
Range("a65000").End(xlUp).Row
Range
("A2").Select
Do Until ActiveCell.Value ComboBox2.Value
    ActiveCell
.Offset(10).Select
Loop

Do Until ActiveCell.Value <> ComboBox2.Value
    
If ActiveCell.Offset(01).Value <> ActiveCell.Offset(-11).Value _
        
Or ActiveCell.Offset(00).Value <> ActiveCell.Offset(-10).Value Then
        ComboBox2
.AddItem ActiveCell.Offset(01).Value
    End 
If
    
ActiveCell.Offset(10).Select
Loop
Application
.ScreenUpdating False


End Sub
Private Sub ComboBox3_Change()

End Sub

Private Sub ComboBox4_Change()

End Sub