|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.6.27
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("总档")
- r = .Cells(Rows.count, 2).End(3).Row
- arr = .[a1].Resize(r, 8)
- ReDim Brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For i = 3 To UBound(arr)
- s = arr(i, 2)
- d(s) = d(s) + val(arr(i, 8))
- Next
- End With
- With Sheets("物料清单")
- r = .Cells(Rows.count, 1).End(3).Row
- For i = 2 To r
- st = .Cells(i, 1)
- If InStr(st, "+") Then
- b = Split(st, "+")
- sum = 0
- For x = 0 To UBound(b)
- sum = sum + d(b(x))
- Next
- .Cells(i, 2) = sum
- Else
- .Cells(i, 2) = d(st)
- End If
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|