Option Explicit
Sub TEST()
Application.ScreenUpdating = False: Sheet1.[A:D].Copy [Sheet2!A1]
With [Sheet2!A1].CurrentRegion
.Sort KEY1:=.Item(4), Order1:=1, Key2:=.Item(1), Order2:=2, Header:=1, Orientation:=1
.Subtotal GroupBy:=4, Function:=xlSum, TotalList:=Array(3), SummaryBelowData:=True
End With
With Sheet2.[A1].CurrentRegion
.Value = .Value
.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(3), SummaryBelowData:=True
End With
With Sheet2.[A1].CurrentRegion
.Cells.ClearOutline: .Offset(.EntireRow.Rows.Count - 2).Clear: .EntireColumn.AutoFit
End With
End Sub作者: Andy2483 時間: 2023-5-8 12:54