|
- Sub 交叉求和v2()
- Dim Arr
- Dim DicNb As Object: Set DicNb = CreateObject("scripting.dictionary")
- Arr = Sheets("数据表").[a1].CurrentRegion
- For i = 3 To UBound(Arr)
- For k = 0 To 2
- For j = 3 + k * 13 To 15 + k * 13
- ' 人数or金额|归属|部门|班组|公司|期间
- kk = Arr(1, j) & "|" & Arr(i, j + 52 - k * 13) & "|" & Arr(i, j + 65 - k * 13) & "|" & _
- Arr(i, j + 78 - k * 13) & "|" & Arr(i, j + 39 - k * 13) & "|" & Arr(2, j)
- DicNb(kk) = DicNb(kk) + Arr(i, j)
- Next
- Next
- Next
- With Sheets("汇总表")
- .Range("F4:Be" & .[a1048576].End(3).Row).ClearContents
- Arr = .[a1].CurrentRegion
- For i = 4 To UBound(Arr)
- For j = 6 To UBound(Arr, 2)
- kk = Arr(i, 2) & "|" & Arr(i, 3) & "|" & Arr(i, 4) & "|" & Arr(i, 5) & "|" & Arr(2, j) & "|" & Arr(3, j)
- Arr(i, j) = DicNb(kk)
- Next
- Next
- .[a1].CurrentRegion = Arr
- End With
- End Sub
复制代码 |
|