Setting the category Label source for a Pie chart

G

Guest

I have a macro to set up the source data for a Piechart as below

With Worksheets("Summary_report").chartobjects(9).chart
.setsourcedata source:=range(range_string), plotby:=xlcolumn
end with
The range_string is constructed by the macro before. As this is a Pie chart
the range is a single column only but the range values are not contiguous.
Similarly I want to set the category labels also programmatically but unable
to find a suitable method / property in Chart object that will achieve this.
The chartwizard method has an optional variant "categorylabels" but does not
seem to work for Pie chart. Any help would be greatly appreciated

Thanks, Sesh
 
P

Peter T

Hi Sesh,

Have you tried the macro recorder?
The bare minimum for "categorylabels", ie x-axis value

..SeriesCollection(1).ApplyDataLabels xlDataLabelsShowLabel

Alternatively for a bit more control
Dim sr As Series, dlbls As Datalabels
set sr = cht.SeriesCollection(1)
sr.HasDataLabels = True
Set dlbls = sr.DataLabels
stop
now look at dlbls in Locals, Alt-v, s

Regards,
Peter T
 

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