CODE
Sub chartLabel()
Dim iPts As Integer
Dim nPts As Integer
Dim aVals As Variant
Dim srs As Series
Dim ws As Worksheet
For Each srs In Charts(1).SeriesCollection
With srs
If .HasDataLabels Then
nPts = .Points.Count
aVals = .Values
For iPts = 1 To nPts
If aVals(iPts) = 0 Then
' If the value is blank or 0, then hide the chart labels
.Points(iPts).HasDataLabel = False
Else
' If there is something great than 0, show all the stuff on the chart
.Points(iPts).ApplyDataLabels xlDataLabelsShowLabelAndPercent, True, False, True, False, True, True, True, True
End If
Next
End If
End With
Next
End sub
Dim iPts As Integer
Dim nPts As Integer
Dim aVals As Variant
Dim srs As Series
Dim ws As Worksheet
For Each srs In Charts(1).SeriesCollection
With srs
If .HasDataLabels Then
nPts = .Points.Count
aVals = .Values
For iPts = 1 To nPts
If aVals(iPts) = 0 Then
' If the value is blank or 0, then hide the chart labels
.Points(iPts).HasDataLabel = False
Else
' If there is something great than 0, show all the stuff on the chart
.Points(iPts).ApplyDataLabels xlDataLabelsShowLabelAndPercent, True, False, True, False, True, True, True, True
End If
Next
End If
End With
Next
End sub
