数据量大时,使用ADO+SQL可能要稍快些.楼主的示例数据太少. Private Sub CommandButton1_Click() Dim n As Long, T As Single n = [a65536].End(xlUp).Row Sheets("统计结果").[a2:g65536] = "" T = Timer Application.ScreenUpdating = False With CreateObject("ADODB.Connection") .Open "provider=microsoft.jet.oledb.4.0;extended properties='excel 8.0;hdr=no;';data source=" & ThisWorkbook.FullName Sheets("统计结果").[a2].CopyFromRecordset .Execute("select F1,F2,F3,F4,SUM(F5),SUM(F6),SUM(F7) from [原始数据$a2:G" & n & "] group by F1,F2,F3,F4") .Close End With Application.ScreenUpdating = True MsgBox "Total:= " & Format(Timer - T, "0.000") & "s" End Sub |