|
参与一下。。。
- Sub ykcbf() '//2024.5.8
- Dim arr, d
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set ws = ThisWorkbook
- Set sh = ws.Sheets("结算表")
- With ws.Sheets("供应商信息")
- zrr = .UsedRange
- For i = 2 To UBound(zrr)
- s = zrr(i, 2)
- d1(s) = i
- Next
- End With
- bt = 1: col = 6
- For Each sht In ws.Sheets
- If sht.Name <> sh.Name And sht.Name <> "说明" And sht.Name <> "数据" And sht.Name <> "供应商信息" Then sht.Delete
- Next
- arr = ws.Sheets("数据").UsedRange
- For i = bt + 1 To UBound(arr)
- s = arr(i, col): ss = arr(i, 2)
- If s <> Empty Then
- If Not d.Exists(s) Then Set d(s) = CreateObject("scripting.dictionary")
- If Not d(s).Exists(ss) Then Set d(s)(ss) = CreateObject("scripting.dictionary")
- d(s)(ss)(i) = i
- End If
- Next i
- On Error Resume Next
- For Each k In d.keys
- zj = 0
- sh.Copy after:=ws.Sheets(ws.Sheets.Count)
- Set sht = ws.Sheets(ws.Sheets.Count)
- ReDim brr(1 To 30, 1 To 7)
- m = 0
- With sht
- .Name = k
- .[a8:g30] = ""
- .[a6] = k
- For x = 3 To 7
- .Cells(6, x) = zrr(d1(k), x)
- Next
- n = 0
- For Each kk In d(k).keys
- Sum = 0
- For Each kkk In d(k)(kk).keys
- m = m + 1: n = n + 1
- brr(m, 1) = n
- For j = 2 To UBound(arr, 2) - 1
- brr(m, j) = arr(kkk, j)
- Next
- Sum = Sum + brr(m, 5)
- Next
- m = m + 1
- brr(m, 2) = kk & " 汇总": brr(m, 5) = Sum
- zj = zj + Sum
- Next
- m = m + 1
- brr(m, 2) = "总计": brr(m, 5) = zj
- .[a8].Resize(m, 7) = brr
- End With
- Next k
- ws.Sheets("数据").Activate
- Set d = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|