|
可以通过VBA实现,而且还可以把每个表的明细复制过来
由于你没有上传附件 我只能假象了一下数据的格式
请参见附件
汇总数据.rar
(19.36 KB, 下载次数: 47)
Sub 汇总()
ActSheet_name = ActiveSheet.Name
Condition = Sheets(ActSheet_name).Cells(1, 2)
Sheets(ActSheet_name).Cells(2, 2) = 0
usemax = Sheets(ActSheet_name).UsedRange.Rows.Count
Rows("10:" & usemax + 1).Clear
For Each sht In Sheets
If sht.Name <> ActSheet_name Then
hmax = sht.UsedRange.Rows.Count
usemax = Sheets(ActSheet_name).UsedRange.Rows.Count
For i = 1 To hmax
If sht.Cells(i, 1) = Condition Then
Sheets(ActSheet_name).Cells(2, 2) = Sheets(ActSheet_name).Cells(2, 2) + sht.Cells(i, 2)
Set rng = sht.Cells(i, 1).Resize(1, sht.UsedRange.Columns.Count)
End If
Next
rng.Copy Sheets(ActSheet_name).Range("A" & usemax + 1)
Set rng = Nothing
End If
Next
End Sub
|
|