加 红色部份 即可!
Sub demo()
Set d = CreateObject("Scripting.Dictionary")
a = Sheet1.UsedRange
For i = 3 To UBound(a)
r = r + 1: If Sheet1.[a2].Offset(r).EntireRow.Hidden Then GoTo 1
Key = a(i, 1)
If Not d.exists(Key) Then
d(Key) = Array(Key, a(i, 2), a(i, 3), a(i, 4), a(i, 5))
Else
d(Key) = Array(Key, d(Key)(1), d(Key)(2) + a(i, 3), d(Key)(3) + a(i, 4), d(Key)(4) + a(i, 5))
End If
1: Next
Sheet4.UsedRange.Offset(1, 0).ClearContents
Sheet4.[a2].Resize(d.Count, 5) = Application.Transpose(Application.Transpose(d.Items))
ary = Range("a65536").End(xlUp).Row
For i = 2 To ary
Cells(i, 6) = Cells(i, 5) / Cells(i, 3)
Next
End Sub