VBA macro (Excel) to create pie chart with legends that exclude 0% values
Posted on 2014-07-21
In a worksheet I've got a simple 2-columns table (name + value); the values can occasionally drop to 0.0%. I'm looking for a macro (VBA) which can reproduce a pie chart on the same sheet which does not show the 0.0% figures - neither the value, nor the label (name).
The below macro does indeed erase the 0%-labels. However, instead of displaying for each label (name) the appendant value as listed in the table, the macro produces percentages referring to the total of this pie charts' values.
I tinkered with the command
(e.g. starting with "Type:= xlDataLabelsShowValue" and take it from there, but got nowhere...).
Any help would be highly appreciated, thank you.
For Each x In Worksheets("abc").ChartObjects(1). _
If InStr(x.DataLabel.Text, Chr(10) & "0.0") > 0 Then