Removing zeros from all data labels at the same time

Peter Davison

Active Member
Joined
Jun 4, 2020
Messages
439
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

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
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,136
Messages
6,123,249
Members
449,093
Latest member
Vincent Khandagale

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