Pie Charts - not including zero values

leifindia

New Member
Joined
Mar 8, 2005
Messages
13
I've been trying to make a macro that creates standard pie charts from rows of data. One pie chart to a row, and the columns have the different types of values.
However I have many columns and in each row there will be many zero values in different columns, and because the pie chart includes all of these in the legend, I doesn't fit them all on.

Is there a way to make the pie chart ignore the zero values?

I hope this makes sense!


I'm using Excel 2007

Ellie

and this is a sample of the macro I am using to create the charts-

Code:
Sub Macro5()
'
' Macro5 Macro
'
    Range("A89:AM89").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range("'DATA'!$A$89:$AM$89")
    ActiveChart.ChartType = xlPie
    ActiveChart.SeriesCollection(1).XValues = "='DATA'!$E$2:$AM$2"
    Range("A90:AM90").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range("'DATA'!$A$90:$AM$90")
    ActiveChart.ChartType = xlPie
    ActiveChart.SeriesCollection(1).XValues = "='DATA'!$E$2:$AM$2"
    ActiveSheet.ChartObjects("Chart 27").Activate
    ActiveChart.ChartArea.Select
    Range("B1").Select
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
It can be a solution (not the best) to change the zero with NULL.
In this case the chart will not display the value, but it will assign the value in Legend.

It is a quick one, not the best solution.

Regards
Catalin
 
Upvote 0
Hi Catalin,

Thanks for your help, but my main problem is the legend. I need the chart area to be fairly small, so I only want the relevent titles in the legend.

Ellie
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top