VBA 代码应用程序或对象错误问题
我已经在 VBA 中编写了一些代码,我的代码在这一行中断,引发应用程序定义或对象定义的错误。
.Formula = "=IF(AND(chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & ">=1;chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & "<=4);chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & ";0)"
我真的很努力检查出了什么问题,但我看起来也很好。请让我知道可能出了什么问题以及如何修复它。
谢谢
I have coded some code in VBA my code breaks at this line raising Application defined or object defined error.
.Formula = "=IF(AND(chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & ">=1;chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & "<=4);chr(34) & ' & chr(34) & Criterion " & i & "'!" & cellAdress & ";0)"
I really tried to check what is wrong but it looks fine too me. Please let me know what could be wrong and how to fix it.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你想要
至少这会产生一个有效且合理的细胞公式,而你的则不然。
将
cellAdress
设置为"A1"
并将i
设置为10
时,结果将是:I think you want
At least this produces a valid and sensible cell formula, your's does not.
With
cellAdress
set to"A1"
andi
set to10
, the result would be:好吧,我现在明白了。在我运行之前,我的 VBA 也不会引发任何错误。也许我看这段代码太久了并且发疯了。我的单元格地址包含 D18,i 包含 1。我有一个名为 Criterion 1 的工作表,该工作表中的单元格的值为 2(当它为空时我也尝试过)。仍然出现此错误,我不知道是什么原因造成的。
Ok I understand it now. My VBA also doesn't raise any errors until I run. Maybe I'm looking on this code for too long and go crazy. My cell Address contains D18 and i contains 1. I do have a sheet called Criterion 1 and the cell in this sheet has a value of 2 (i also tried when it was empty). Still this error is raised and I don't know what is causing it.