ActiveChart.ADD Fails

  • Thread starter Thread starter Sean McPoland
  • Start date Start date
S

Sean McPoland

I have recorded a macro to add a new chart sheet but when
running the macro is step mode it fails:

the statements are
Charts.Add
ActiveChart.ChartType = xlSurface

and I get

Runtime error '1004'
method Charttype of object _chart failed...

any ideas - this is bog standard code

regards
Sean
 
Hi Sean,

The reason it fails is there is not enough data in the chart to change
it to a surface chart.
Try adding data to your chart before changing the chart type.

Try to change the chart, that is created by the Charts.Add command,
manually and you will see an explanation.

Cheers
Andy
 
Hi Andy and thanks,

so what your really saying is that the Macro recorder is
at fault in that is does not order the statements in the
correct manner for creating a chart.

ie Add chart
add Series Data
then change charttype.....

Bujjer - who would have guessed that the macro recorder
would have got it so wrong......

Thanks again, will try it out later
regards
Sean
 
Anything that the macro recorder spits out has to be used with care. There are a few things like
this that it puts lines in the wrong order. Also remember that it records you while you do
things, and working with a mouse and selecting everything before working on it is very inefficient.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top