user1445301
user1445301

Reputation: 31

Put a formula in excel chart

I want to fill a text box on an Excel chart using VBA. I tried this:

 ActiveSheet.ChartObjects("Chart 1").Chart.Shapes(1).Formula = "Sheet1!A1"

and it doesn't work, but this does:

 ActiveSheet.ChartObjects("Chart 1").Chart.Shapes(1).Select
 Selection.Formula = "=Sheet1!A1"

There probably is something I need to put between Shapes(1) and .Formula, but I can't find it. Any suggestions?

Upvotes: 3

Views: 1694

Answers (1)

Jon Peltier
Jon Peltier

Reputation: 6073

Note that the second formula (the one that works) includes an equals sign before the sheet name:

"=Sheet1!A1"

while the first does not:

"Sheet1!A1"

Upvotes: 3

Related Questions