|
参与一下。。。- Sub ykcbf() '//2024.1.26
- Set d = CreateObject("Scripting.Dictionary")
- Application.ScreenUpdating = False
- Set sh = ThisWorkbook.Sheets("Sheet1")
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- If sht.UsedRange.Count > 5 Then
- With sht
- arr = .UsedRange
- For j = 2 To UBound(arr, 2)
- If arr(8, j) <> Empty Then
- s = .Name: ss = Month(arr(8, j))
- If Not d.exists(s) Then Set d(s) = CreateObject("Scripting.Dictionary")
- d(s)(ss) = d(s)(ss) + arr(7, j)
- End If
- Next
- End With
- End If
- End If
- Next
- With sh
- .[h5:u10000] = ""
- .[y5:ak10000] = ""
- .[h5].Resize(d.Count, 1) = Application.Transpose(d.keys)
- arr = .Range("h4:u" & d.Count + 4)
- For i = 2 To UBound(arr)
- Sum = 0
- For j = 2 To UBound(arr, 2) - 1
- s = arr(i, 1)
- If d.exists(s) Then
- arr(i, j) = d(s)(Val(arr(1, j)))
- Sum = Sum + arr(i, j)
- End If
- Next
- arr(i, UBound(arr, 2)) = Sum
- Next
- .Range("h4:u" & d.Count + 4) = arr
- .Range("i5:u" & d.Count + 4).Copy .Range("y5")
- brr = .Range("v4:ak" & d.Count + 4)
- For i = 2 To UBound(brr)
- num = brr(i, 1) + brr(i, 2) + brr(i, 3)
- For j = 4 To UBound(brr, 2)
- brr(i, j) = brr(i, j) * num
- Next
- Next
- .Range("v4:ak" & d.Count + 4) = brr
- ActiveWindow.DisplayZeros = False
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|