为什么我会收到运行时错误“1004”在 MacBook 上,当我从 PC 版本的 VBA 复制代码时
我是 VBA 和学习新手;但是,我也在我的 MAC 而不是 PC 上运行 VBA。话虽如此,我将代码复制下来,就像我在 PC 使用的 VBA 中看到的那样,我收到运行时错误“1004”对象“_Global”的方法“范围”失败。有人可以向我解释一下这是为什么吗?
我的代码很简单: MonthArray(1) = Range("myMonths").Cells(i,1).value
大家有什么想法吗?
Sub Array_OneDimension()
Dim MonthArray(1 To 12) As String
Dim i As Byte
For i = 1 To 12
MonthArray(i) = Range("myMonths").Cells(i, 1).Value 'This is where the error is
Next i
End Sub
我期望代码循环遍历范围并提取本地窗口中的值。
I am new to VBA and learning; however, I am also running VBA on my MAC instead of PC. That being said, I copy the code down just like I have seen in VBA used by PCs and I get a run-time Error '1004'Method 'Range' of object '_Global' failed. Can someone please explain to me why that is?
My code is simple: MonthArray(1) = Range("myMonths").Cells(i,1).value
Thoughts anyone?
Sub Array_OneDimension()
Dim MonthArray(1 To 12) As String
Dim i As Byte
For i = 1 To 12
MonthArray(i) = Range("myMonths").Cells(i, 1).Value 'This is where the error is
Next i
End Sub
I was expecting the code to loop through the range and pull out the value in the locals window.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论