|
参与一下。。。
- Sub ykcbf() '//2024.9.18
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- ReDim brr(1 To 10000, 1 To 1)
- For Each sht In Sheets
- If Val(sht.Name) Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 19)
- End With
- For i = 2 To UBound(arr)
- If Val(arr(i, 5)) <> 0 Then
- s = arr(i, 1)
- If Not d1.exists(s) Then
- m = m + 1
- d1(s) = m
- brr(m, 1) = s
- End If
- For j = 4 To 5
- s = arr(i, 1) & "|" & arr(4, j)
- d(s) = d(s) + arr(i, j)
- Next
- For j = 7 To 19
- s = arr(i, 1) & "|" & arr(5, j)
- d(s) = d(s) + arr(i, j)
- Next
- End If
- Next
- End If
- Next
- With Sheets("汇总")
- .[a2:a15] = ""
- .[a2].Resize(m, 1) = brr
- .[a2].Resize(m, 1).Sort .[a2], 1
- arr = .[a1:p16].Value
- For i = 2 To UBound(arr)
- For j = 2 To 15
- s = arr(i, 1) & "|" & arr(1, j)
- If d.exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .[a1:p16].Value = arr
- For i = 2 To UBound(arr)
- .Cells(i, 16).Value = Application.Sum(.Cells(i, 2).Resize(, 14))
- If .Cells(i, 2).Value <> 0 Then
- .Cells(i, 17).Value = .Cells(i, 16).Value / .Cells(i, 2).Value / 100
- Else
- .Cells(i, 17).Value = ""
- End If
- Next
- For j = 2 To 16
- .Cells(16, j).Value = Application.Sum(.Cells(2, j).Resize(m))
- Next
- ActiveWindow.DisplayZeros = False
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|