|
- Sub ykcbf() '//2023.3.17
- Dim arr, brr(1 To 100000, 1 To 10), d
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- arr = Sheets("应发比例").[a1].CurrentRegion
- For i = 2 To UBound(arr)
- s = arr(i, 3)
- d1(s) = arr(i, 4)
- Next
- arr = Sheets("2022全年明细").UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 2) <> Empty Then
- yf = Right(CStr(arr(i, 2)), 2)
- s = arr(i, 4) & "|" & arr(i, 15) & "|" & yf
- If Not d.exists(s) Then
- d(s) = Array(arr(i, 26), d1(arr(i, 25)), arr(i, 22))
- Else
- t = d(s)
- t(0) = t(0) + arr(i, 26)
- t(2) = t(2) + arr(i, 22)
- d(s) = t
- End If
- s2 = arr(i, 4) & "|" & arr(i, 15)
- d2(s2) = ""
- End If
- Next
- t = d.items
- For Each k In d2.keys
- m = m + 1
- brr(m, 1) = Split(k, "|")(0)
- brr(m, 3) = Split(k, "|")(1)
- Next
- On Error Resume Next
- With Sheets("2022酬金发放核对表")
- .UsedRange.Offset(1).Clear
- .Columns(4).NumberFormatLocal = "@"
- .[b2].Resize(m, 3) = brr
- c = .Cells(1, Columns.Count).End(xlToLeft).Column
- arr = .[a1].Resize(m + 1, c)
- For i = 2 To UBound(arr)
- For j = 5 To c Step 4
- s = arr(i, 2) & "|" & arr(i, 4) & "|" & CStr(arr(1, j))
- If d.exists(s) Then
- arr(i, j) = d(s)(0)
- arr(i, j + 1) = Format(d(s)(1), "0.00%")
- arr(i, j + 2) = Format(d(s)(0) / d(s)(2), "0.00%")
- End If
- Next
- Next
- .[a1].Resize(m + 1, c) = arr
- .[a1].Resize(m + 1, c).Borders.LineStyle = 1
- End With
- End Sub
复制代码
代码如下: |
|