我只是想运行下面的代码,但我无法创建 ScriptingDictionary 对象;我不断收到错误:
运行时错误“429”:ActiveX 组件无法创建对象。
我也尝试使用关键字“New”创建对象,但没有成功。我需要导入任何库吗?
谢谢您的帮助。
Option Explicit
Sub GetDuplicates():
Dim i As Long, arr As Variant, tmp As Variant
Dim dict As Object
Set dict = CreateObject("Scripting.Dictionary")
arr = Range(Cells(1, "ID"), Cells(Rows.Count, "ID").End(xlUp)).Value
'build dictionary
For i = 2 To UBound(arr, 1)
If dict.exists(arr(i, 1)) Then
Cells(i, 3).Value = "Repeat"
Else
dict.Item(arr(i, 1)) = Array(i)
End If
Next i
End Sub