Excel vba 更改形状公式而不选择形状
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13180429/
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
Excel vba Change shape formula without selecting shape
提问by evoandy
I'm trying to change the formula within a shape without selecting it but keep getting a run-time error.
我正在尝试更改形状内的公式而不选择它,但不断收到运行时错误。
Below are some of the code I've tried so far:
以下是我迄今为止尝试过的一些代码:
Sheets("Quote").Shapes.Range(Array("Rectangle 87")).Formula = " =CommAnnualOutput"
Sheets("Quote").Shapes("Rectangle 87").Formula = " =CommAnnualOutput"
Sheets("Quote").Shapes("Rectangle 87").DrawingObjects.Formula = " =CommAnnualOutput"
None of these seem to work. Is there a way to change the formula without selecting the shape first?
这些似乎都不起作用。有没有办法在不先选择形状的情况下更改公式?
回答by K_B
Please find the answer to your question here:
请在此处找到您问题的答案:
Good luck
祝你好运
回答by panda-34
You missed two characters on your last try. That would be
上次尝试时您错过了两个字符。那将是
Sheets("Quote").Shapes("Rectangle 87").DrawingObject.Formula = "=CommAnnualOutput"