Removing zeros from all data labels at the same time

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
438
Office Version
  1. 365
Platform
  1. Windows
I know how to remove data labels that are showing a zero individually, but is there a way of removing zeros in an excel chart for all data labels at the same time?
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Number/ Format Code (Custom) on the data label

Code:
0;-0;;
 
Upvote 0
When I enter the above it shows all the zeros on the chart (see below)
1707140320119.png
 
Upvote 0
What does your dataset look like? Have you tried hiding zeros in the advanced options for the sheet

Screenshot 2024-02-05 092323.png
 
Upvote 0
This is currently my setting, which is fine in cells, but doesn't remove zeros on the chart. Even though the cell is not showing a zero the chart thinks it is a zero.
See below
1707143333563.png
 
Upvote 0
There is a messy way of removing all zeros at the same time, doesn't look good but seems to work.
Add an if statement to check for a zero and if it is zero make it say #N/A.
I suppose I could then have a conditional format to say if a cell says #N/A change it to white writing so you can't see the word.
 
Upvote 0
Did you apply that custom number format to the data labels for every series?
 
Upvote 0
No that is what I was trying to avoid, I am able to do it a legend at a time, but where you have 50 or so different legends I was looking for a method that would change all at the same time.
As I mentioned above, that is an option, but messy.
Thanks for getting back to me.
 
Upvote 0
IMO if you have 50 different series, your chart is already in trouble. ;)

You could use code to apply the number format to all of them, or use your error method.

Edit: just occurred to me that if your data label formats are linked to source, as they usually are by default, then apply that number format to the source cells.
 
Upvote 0
this work

VBA Code:
Sub SetNumFormat()
    Dim chrt As ChartObject
    Dim ser As Series
    
    Set chrt = ThisWorkbook.Sheets("Sheet1").ChartObjects("Chart 1")  ' your chart
    
    For Each ser In myChart.Chart.SeriesCollection
        ser.Format.NumberFormat = "0;-0;;"
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,091
Messages
6,123,062
Members
449,089
Latest member
ikke

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