Option Explicit
Sub TEST2()
Dim ar, br, i&, j&, k&, r&, n&
Application.ScreenUpdating = False
ar = [A1].CurrentRegion.Value
ReDim br(1 To UBound(ar, 2), 1 To 4)
For j = 1 To UBound(ar, 2) Step 4
r = r + 1
n = j - 1: br(r, 1) = ar(2, j)
For i = 2 To UBound(ar)
If ar(i, j) = br(r, 1) Then
For k = 2 To 4
br(r, k) = br(r, k) + ar(i, n + k)
Next k
End If
Next i
Next j
[af1].CurrentRegion.ClearContents
[af1].Resize(, 4) = Array("日期", "A", "B", "R")
[AF2].Resize(r, 4) = br
Application.ScreenUpdating = True
Beep
End Sub
|