Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Suppress 0 in Pie Chart

Status
Not open for further replies.

wiginprov

Technical User
May 5, 2001
35
US
I have several pie charts in a user workbook, where the source data sometimes displays "0%". In these cases, I want to suppress the label and the value.

A possible solution is to put a button next to the graph, with a macro which deletes this text. I have played with the syntax a bit, but no luck thus far. (Dynamic range names and NA() in the source range did not resolve this issue.)

Any ideas?

Thank you.


 
wiginprov,,

Ive dont this sort of thing before but always had the luxury of haveing the chart displayed by the user clicking a button to start off with, in this case you can have code that runs from the button click that hides the rows/columns that contain zero. A hidden value wont appear in a chart. Hiding the unwanted values is better than deleting them.

use this code if you cant get your own together,,,

with thisworkbook.worksheets("MyDataSheet")
iDataColumn = .range("myDataRange").columns(2).column '\\column 2 being your data column
for iCount = 1 to range("myDataRange").rows.count
if isnumeric(.cells(icount, iDataColumn).value) then
if.cells(icount, iDataColumn).value = 0 then
.cells(icount, iDataColumn).entirerow.hidden = true
end if
end if
next icount
end with

of course, adjust the code for your own data range, and accordingly for if your data is arranged by columns rather than rows....

I used a named range for conveniance only, you will find that it helps somtimes though,,,

just ask if you have any more questions,,,,


kaah
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top