View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.charting
 
Posts: n/a
Default chart legend moves!

Thanks Jon. That solves the minor issue of the title. As I wrote in
my posting, I did record a macro to get familiar with the syntax, but
even that code wouldn't work. It's a non-issue now that I know how to
link the title in the formula bar.

My original concern still remains. Is there a way to keep the legend
from moving aroudn without setting the placement? Or can I set the
placemetn and still adjust the size/shape of the legend?

Jon Peltier wrote:
"Chart" is a keyword in VBA, so you should not be using it as a variable
name.

You can easily link a title to a cell without VBA. Select the title, type =
in the formula bar, and click on the cell.

If you must use VBA, use the macro recorder while you do something to get a
handle on the syntax. You need something that resembles this:

With Sheet6.ChartObjects(chart).Chart
.ChartTitle.Text = Sheet6.Cells(r1, 1).Value
End With

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______


wrote in message
oups.com...
I'm also having trouble changing the chart title using VBA. I've tried
recording a macro for it, but then I got an error when I ran the
recorded macro! One variation of the code I am trying to use is

With Sheet6.ChartObjects(chart)
.ChartTitle.Name = Cells(r1, 1).Value
End With

chart is a string variable with the name of the chart, in this case
chrt.Indicator1.

Thanks for your insight!