dimanche 27 septembre 2020

VBA Sort ignored inside ElseIf

Could anyone please explain to me why it is that the line below that is trying to filter my data by E1 will not work in the first location (see "<<< 1st Location"), but it works fine in the second location (see "<<< 2nd Location"). No error thrown for the first location, it just seems to skip it.

Private Sub CommandButton31_Click()

Call CreateDataSheet

If ToggleButtonFrontTeam.Value = False And ComboBox1.Value = "Designer" Then
    Call FilterFrontTeamSortDesigner
    Sheets("Data_Sheet").Range("A2:I10000").Sort Key1:=Range("E1"), Order1:=xlAscending, Header:=xlNo   '<<< 1st Location
ElseIf ToggleButtonMidTeam.Value = False And ComboBox1.Value = "Designer" Then
    Call FilterMidTeamSortDesigner

ElseIf ToggleButtonRearTeam.Value = False And ComboBox1.Value = "Designer" Then
    Call FilterRearTeamSortDesigner

Else
    Unload Me

End If

Sheets("Data_Sheet").Range("A2:I10000").Sort Key1:=Range("E1"), Order1:=xlAscending, Header:=xlNo    '<<< 2nd Location

Unload Me
End Sub

Aucun commentaire:

Enregistrer un commentaire