|
本帖最后由 ykcbf1100 于 2024-7-20 20:59 编辑
参与一下。。。
- Sub ykcbf() '//2024.7.20
- Set d = CreateObject("Scripting.Dictionary")
- r1 = Cells(Rows.Count, 2).End(3).Row
- r2 = Cells(Rows.Count, 10).End(3).Row
- Max = IIf(r1 < r2, r2, r1) + 2
- Cells(Max, 1).Resize(23 - Max,18).ClearContents
- For i = 10 To r1
- s = Cells(i, 3) & "|" & Cells(i, 4)
- d(s) = d(s) + Cells(i, 5)
- Next
- ReDim brr(1 To d.Count, 1 To 3)
- For Each k In d.keys
- m = m + 1
- brr(m, 1) = Split(k, "|")(0)
- brr(m, 2) = Split(k, "|")(1)
- brr(m, 3) = d(k)
- Next
- If m > 5 Then
- For i = 1 To m - 5
- Cells(Max + i, 1).EntireRow.Insert
- Next i
- End If
- Cells(Max, 3).Resize(m, 3) = brr
- Cells(Max, 11).Resize(m, 3) = brr
- Cells(Max, 1).Resize(m) = "合计:"
- d.RemoveAll
- For i = 10 To r2
- s = Cells(i, 11) & "|" & Cells(i, 12)
- d(s) = d(s) + Cells(i, 13)
- Next
- For i = Max To m + Max - 1
- s = Cells(i, 11) & "|" & Cells(i, 12)
- Cells(i, 13) = d(s)
- Cells(i, 18) = Cells(i, 5) - Cells(i, 13)
- Next
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|