|
楼主 |
发表于 2012-8-9 14:36
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我将KCFONG老师dic(y) = dic(y) + rng(r, 6)改为dic.Add y, rng(r, 6)后也运行正常:
Sub test4()
Range("F2:F" & Rows.Count).ClearContents
Set dic = CreateObject("scripting.dictionary")
rng = Sheets("期初数量金额").UsedRange
For r = 2 To UBound(rng)
y = rng(r, 1) & rng(r, 2) & rng(r, 3) & rng(r, 4) & rng(r, 5)
dic.Add y, rng(r, 6)
Next r
rng1 = Sheets("成品收付存").UsedRange
For r = 2 To UBound(rng1)
y = rng1(r, 1) & rng1(r, 2) & rng1(r, 3) & rng1(r, 4) & rng1(r, 5)
If dic.Exists(y) Then rng1(r, 6) = dic(y)
Next r
Sheets("成品收付存").UsedRange = rng1
End Sub
|
|