感谢大神分享!
不过我想请教一个问题: 更新库存台账() 里的以下几个步骤看不太懂,能否解答一下思路呢?感激不尽
Set d = CreateObject("Scripting.Dictionary")
ReDim a(1 To 6, 1 To UBound(arr) - 1)
For i = 2 To UBound(arr)
n = n + 1
d(arr(i, 1)) = n
For j = 1 To 3
a(j, n) = arr(i, j)
Next
a(6, n) = arr(i, 3)
Next
这几步也看不懂
If Not d.Exists(arr(i, 2)) Then
n = n + 1: ReDim Preserve a(1 To 6, 1 To n)
d(arr(i, 2)) = n
a(1, n) = arr(i, 2) '存货编码
a(2, n) = arr(i, 3) '物料名称
a(4, n) = arr(i, 6) '累计入
a(5, n) = arr(i, 5) '累计出
a(6, n) = IIf(arr(i, 5) > 0, arr(i, 5), arr(i, 6)) '结存
Else
m = d.Item(arr(i, 2))
a(4, m) = a(4, m) + arr(i, 6) '累计入
a(5, m) = a(5, m) + arr(i, 5) '累计出
a(6, m) = a(3, m) + a(4, m) - a(5, m) '结存
End If |