Declaring a dictionary in VBA

北城余情 提交于 2020-01-04 19:10:27

问题


I'm getting an error Run-time error '424': Object required when I try to create a dictionary in VBA. My code is shown below:

Private Sub data()
Dim dicti As Object
Set dicti = CreateObject(Scripting.Dictionary)  

How can I fix this issue?


回答1:


Try,

dim dicti As Object
Set dicti = CreateObject("Scripting.Dictionary") 

Alternately, swap the late binding for early binding by accessing the VBE's Tools, References and including Microsoft Scripting Runtime with a check.

dim dicti as new Scripting.Dictionary



来源:https://stackoverflow.com/questions/51233284/declaring-a-dictionary-in-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!