Can not get Excel macros to format/save charts--help??? :(((((

A

AccessQuestion

Help??:((( I've spent the last 5 days searching on this forum for problems
similar to what I have but no luck! I am trying to use Excel macro to create
a simple bar chart and to format the chart type/etc...but the macro keeps
erroring when I try to run it.
The debug points to "
'
Set ActiveChart = ActiveSheet.ChartObjects(Chart1)" run time error 1004.
No matter what I name the chart, it errors.
I'm advanced at Excel but not editing macros with VB.
I'm at my wits end and hope that someone can help me :((
 
A

Andy Pope

Hi,

You do not set the Activechart object in that way. It is automatically
assigned by activating the chart.

Activesheet.chartobjects("Chart 1").activate

Now you can use the Activechart object, for example.

Msgbox "Chart has " & Activechart.seriescollection.count & " series"

Cheers
Andy
 
A

AccessQuestion

Hi Andy,
Thanks for your answer but I'm not sure I understand.
This is my code and the debugger keeps stopping on ActiveChart.SetSourceData
line.


'
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.PlotArea.Select
' ActiveChart.SetSourceData
 

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

Top