Windows XP Change graph type in VBA


Joined
Sep 2, 2008
Messages
5
Reaction score
0
Hi all,



I woud like to know if it's possible to change a graph's type, by VBA code. For exemple, i would like to change an histogramme graph into a sector's graph.



thanks in advance for all tips,
 
Ad

Advertisements

Joined
Sep 3, 2008
Messages
164
Reaction score
5
To change the type of chart use similar code. This creates, then changes an existing, selected chart.

'this is the range for my chart data
Range("A1:Q11").Select
'this adds the chart
Charts.Add
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("A1:Q11"), PlotBy _
:=xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
'this selects the existing chart
ActiveChart.ChartArea.Select
'this selects the new chart type
ActiveChart.ChartType = xl3DPie
 
Ad

Advertisements


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