MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Pivot table and graphing problems????

Posted by merlin on January 05, 2001 3:02 PM

Hi all. How are you?

Here's my problem. I'm trying to make a macro that will generate a pivot table from imported data every month Then from the pivot table make a graph. (I can do all that) But i run into problems when i try to format the graph's size. When the macro runs it doesn't know the chart name. (i think)

My questions:
The VBA code generates this:

ActiveSheet.Shapes("Chart 1").ScaleWidth 1.28, msoFalse, msoScaleFromTopLeft

When i took this code out, the macro worked.

I believe the problem is with the name "Chart 1". What should I put in for "Chart 1" to get the macro to work?

2) I also want the prevous graph/chart deleted every time i run the macro. How can I delete the chart if i don't know the name whenever i refresh the data?

thanks in advance,

Posted by Dave on January 05, 2001 6:10 PM

Hi Brian

If you only ever have the one chart on the sheet then you could use


...Or set the chart name like:

ActiveSheet.ChartObjects(1).Name = ActiveSheet.Name


OzGrid Business Applications