0

I am facing a problem while coding VBA. I have created a pie chart and every Method that is available to display the Data used for the Chart is not very good looking. The only one that fits my needs is the ElementDataLabelCallout Method, but it only shows the percentage and not like for example ElementDataLabelShow the raw data. Is there a way to edit the VBA Code so that the Callout Method displays the data instead of the percentages ?

Set chrt = Sheets(Chart).ChartObjects.Add(Left:=0, Width:=540, Top:=0, Height:=420)
chrt.Chart.ChartType = xlPie
chrt.Chart.SetSourceData Source:=Sheets(Sheetname).Range("A1:B6"), PlotBy:=xlColumns
chrt.Chart.SetElement msoElementDataLabelCallout

This is how I did it but it displays only the percentage in the pie chart.

2 Answers 2

1

Always try Macro recording it writes everything :)

chrt.Chart.FullSeriesCollection(1).DataLabels.ShowValue = True
chrt.Chart.FullSeriesCollection(1).DataLabels.ShowPercentage = False
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! just did that myself but yours is even better!
0

I have found the solution myself with recording a Macro its somewhat like this:

ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.FullSeriesCollection(1).DataLabels.Select
Selection.ShowPercentage = False
Selection.ShowValue = True

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.