Excel VBA合并和求和列表错误429 Active X无法创建对象

时间:2018-07-30 22:20:39

标签: vba excel-vba merge sum

我有此代码,它以前在Windows版本的Excel 2016中工作。 我现在只有Mac excel2016。基本上,我有来自多个配方的成分数据集,这些数据集创建了具有3列的列表。通过此列表,我想合并相似成分的列“ a”并求和“ c”列中的值。列“ b”是单位。我收到错误消息x,无法创建对象429

“合并和汇总购物清单”

Dim WorkRng As Range

Dim Dic As Variant
Dim Dic2 As Variant

Dim arr As Variant
Dim arr2 As Variant
On Error Resume Next

Set WorkRng = Application.Worksheets("Shopping List").Range("A2:C1000")
Set Dic = CreateObject("Scripting.Dictionary")
Set Dic2 = CreateObject("Script.Dictionary")




arr = WorkRng.Value

For i = 1 To UBound(arr, 1)

Dic(arr(i, 1)) = Dic(arr(i, 1)) + arr(i, 3)

Next

For ii = 1 To UBound(arr2, 2)
Dic2(arr2(ii, 2)) = Dic2(arr2(ii, 2))


Next

Application.ScreenUpdating = False

WorkRng.ClearContents
WorkRng.Range("A1").Resize(Dic.Count, 1) = 
Application.WorksheetFunction.Transpose(Dic.keys)
WorkRng.Range("B1").Resize(Dic.Count, 1) = 
Application.WorksheetFunction.Transpose(Dic2.keys)
WorkRng.Range("C1").Resize(Dic.Count, 1) = 
Application.WorksheetFunction.Transpose(Dic.items)

Application.ScreenUpdating = True

0 个答案:

没有答案