|
不知道是不是你的需求啊,你运行看看
Sub tt()
Dim arr, brr
Dim i, j, k, m As Long
Dim sht As Worksheet
Sheets("总表").Range("a1").CurrentRegion.Offset(2, 1).ClearContents
arr = Sheets("总表").Range("a1").CurrentRegion
Application.DisplayAlerts = False
'删掉空表
For Each sht In Sheets
If Application.WorksheetFunction.CountA(sht.Cells) = 0 Then sht.Delete
Next
Application.DisplayAlerts = True
For i = 3 To UBound(arr)
For Each sht In Sheets
If sht.Name <> "总表" Then
brr = sht.Range("a1").CurrentRegion
For j = 3 To UBound(brr)
If arr(i, 1) = brr(j, 1) Then
For k = 4 To UBound(brr, 2)
If arr(2, 2) = brr(2, k) Then arr(i, 2) = arr(i, 2) + brr(j, k)
If arr(2, 3) = brr(2, k) Then arr(i, 3) = arr(i, 3) + brr(j, k)
If arr(2, 4) = brr(2, k) Then arr(i, 4) = arr(i, 4) + brr(j, k)
Next
End If
Next
End If
Next
Next
Sheet1.Range("a1").CurrentRegion = arr
End Sub |
|