|
在wujin这张表里面有订单对应的物料
物料有重复,希望能把物料的数量合并并放在wujin plan这个表格里面
已根据逻辑写了代码,但是由于对vba语言不熟悉
代码运行不了,求大神帮忙看下问题在哪里
Sub test2()
Dim arr, i, j, k, n, pos, d As Object
arr = Sheets("wujin").[a1].CurrentRegion
pos = Array(0, 9, 10, 11, 12, 13, 15)
Set d = CreateObject("Scripting.Dictionary")
ReDim brr(1 To Rows.Count, 1 To 20)
For i = 3 To UBound(arr, 1)
m = 0
If Not d.Exists(arr(i, 9)) Then
d(arr(i, 9)) = arr(i, 14)
n = n + 1
For j = 1 To UBound(pos): brr(n, j) = arr(i, pos(j)): Next
For j = 4 To UBound(arr, 1)
If d.Exists(arr(j, 9)) Then
d(arr(i, 9)) = d(arr(i, 9)) + arr(j, 14)
End If
Next
d(arr(i, 9)) = k
End If
Next
For k = 2 To UBound(arr, 1)
brr(k, 6) = d(brr(k, 1))
Next
End Sub
••••ˇˇˇˇ
|
|