|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.1.16
- Dim arr, brr, d
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Dim tm: tm = Timer
- Set d = CreateObject("Scripting.Dictionary")
- b = [{3,99,11,7,9,99,99,2,5,4,99}]
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 2).End(3).Row
- arr = .Range("b2:n" & r)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 3)
- If Not d.exists(s) Then
- d(s) = Array(1, arr(i, 11), arr(i, 7), arr(i, 9), arr(i, 7), arr(i, 9), arr(i, 2), arr(i, 5), arr(i, 4))
- Else
- t = d(s)
- t(0) = t(0) + 1
- t(3) = t(3) + arr(i, 7)
- t(4) = t(4) + arr(i, 9)
- d(s) = t
- End If
- Next
- With Sheets("Sheet2")
- r = .Cells(Rows.Count, 2).End(3).Row
- arr = .Range("b2:l" & r)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If d.exists(s) Then
- t = d(s)
- For j = 2 To UBound(b) - 1
- arr(i, j) = t(j - 2)
- Next
- arr(i, 11) = arr(i, 2) * arr(i, 3)
- End If
- Next
- .Range("b2:l" & r) = arr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|