vba 如何修复“编译错误:需要对象”错误?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4472744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:25:48 来源:igfitidea点击:
How to fix "Compile Error: Object Required" error?
提问by xbonez
This is my very first time with VBA. For the following code fragment:
这是我第一次使用 VBA。对于以下代码片段:
Dim i As Integer
Set i = 0
For Each v In dictDT.Keys
Cells(10, 5 + i) = dictDT.Item(v)
i = i + 1
Next
I keep getting this error:
我不断收到此错误:
Compile Error: Object Required
What am I doing wrong?
我究竟做错了什么?
回答by Dick Kusleika
Change
改变
Set i = 0
to
到
i = 0
Only objects require the Set keyword. Other variable types do not.
只有对象需要 Set 关键字。其他变量类型没有。