|
本帖最后由 ykcbf1100 于 2024-5-16 20:15 编辑
参与一下。。。- Sub ykcbf87() '//2024.5.16
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("数据源").UsedRange
- ReDim brr(1 To UBound(arr), 1 To 7)
- On Error Resume Next
- For i = 2 To UBound(arr)
- If Val(arr(i, 1)) Then
- s = arr(i, 2) & "|" & arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 8)
- If Not d.Exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 2)
- brr(m, 2) = arr(i, 3)
- brr(m, 3) = arr(i, 4)
- brr(m, 4) = arr(i, 8)
- Else
- r = d(s)
- brr(r, 7) = brr(r, 7) + arr(i, 9) + arr(i, 10)
- brr(r, 5) = brr(r, 5) + arr(i, 10)
- brr(r, 6) = brr(r, 5) / brr(r, 7)
- End If
-
- End If
- Next
- With Sheets("统计")
- .UsedRange.Offset(3) = ""
- .Columns(6).NumberFormatLocal = "0.000%"
- .Range("a4").Resize(m, 6) = brr
- .Range("a4").Resize(m, 6).Borders.LineStyle = 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|