Private Sub CommandButton1_Click()
Dim cell As Range
Dim depart As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Range("A3:F100").Sort Key1:=Range("B3"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A3:F100").Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(4), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Range("A3").Select
End Sub
Private Sub CommandButton2_Click()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
On Error Resume Next
With Selection
.AutoFilter Field:=1
.AutoFilter Field:=2
.AutoFilter Field:=3
.AutoFilter Field:=4
.AutoFilter Field:=5
.AutoFilter Field:=6
End With
Range("A3:F100").Sort Key1:=Range("E3"), Order1:=xlAscending, Key2:=Range("F3") _
, Order2:=xlAscending, Key3:=Range("B3"), Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, DataOption3:=xlSortNormal
Range("A3:F100").Subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(4), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Range("A3").Select
End Sub