Excel vba Change shape formula without selecting s

2019-08-16 16:37发布

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?

2条回答
萌系小妹纸
2楼-- · 2019-08-16 16:39

Please find the answer to your question here:

Link cell with Excel Shape

Good luck

查看更多
叼着烟拽天下
3楼-- · 2019-08-16 16:52

You missed two characters on your last try. That would be

Sheets("Quote").Shapes("Rectangle 87").DrawingObject.Formula = "=CommAnnualOutput"
查看更多
登录 后发表回答