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?
 
Thanks for coming back so quick, appreciate that.
I was looking to achieve with a formula, however I will try the VBA.
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
I tried the code, but it did not like the line -
ser.Format.NumberFormat = "0;-0;;"
also should mychart. be chrt?
 
Upvote 0
Sorry, try this

VBA Code:
Sub SetNumFormat()
    Dim chrt As ChartObject
    Dim ser As Series
    Dim pnt As Point
    
    Set chrt = ThisWorkbook.Sheets("Sheet4").ChartObjects("Chart 1")  ' your chart
    
    For Each ser In chrt.Chart.SeriesCollection
        For Each pnt In ser.Points
            pnt.ApplyDataLabels
            pnt.DataLabel.NumberFormat = "0;-0;;"
        Next 
    Next
End Sub
 
Upvote 0
I tried the code above, but it didn't remove the zeros.
It's not a problem I'm going to use the "If" and if it is zero then put a #N/A in the cell and then it does remove the zeros.
 
Upvote 0
Did you try applying the number format to the cells?
 
Upvote 0
Yes I tried the number format, but it only works one series at a time and I was looking for a solution that I could do something once and it removed all Data Labels with Zero
 
Upvote 0

Forum statistics

Threads
1,215,079
Messages
6,123,000
Members
449,092
Latest member
masterms

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