|
参与一下。。。
- Sub ykcbf() '//2024.4.16
- Set d = CreateObject("Scripting.Dictionary")
- r = Cells(Rows.Count, 1).End(3).Row
- arr = [a1].Resize(r, 8)
- ReDim brr(1 To UBound(arr), 1 To 9)
- m = 1: n = 1
- brr(1, 1) = "TYPE": brr(1, 9) = "合计"
- On Error Resume Next
- For i = 2 To UBound(arr)
- s = arr(i, 3)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- brr(m, 9) = 0
- End If
- s = Mid(arr(i, 4), 8, 1)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = s
- End If
- r = d(arr(i, 3)): c = d(Mid(arr(i, 4), 8, 1))
- brr(r, c) = brr(r, c) + arr(i, 7)
- Next
- For i = 2 To UBound(brr)
- brr(i, 9) = 0
- For j = 2 To UBound(brr, 2) - 1
- brr(i, 9) = brr(i, 9) + brr(i, j)
- Next
- Next
- [k1:s8].Clear
- [k1].Resize(m, 9) = brr
- [k1].Resize(m, 9).Borders.LineStyle = 1
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|