Data labels every second point

  • Thread starter Thread starter Klemen25
  • Start date Start date
K

Klemen25

Hello

I found and successfully used the below stated macro for adding data
labels on the last data point.
Could someone of you experts help me with creating a macro, that would
add data labels on every second point (when there are a lot of data
the labels are too crowded, and to erase manually every second label
is quite time consuming)

Thank you all!


Sub LastPoinLabel()
Dim mySrs As Series
Dim nPts As Long
On Error GoTo Error
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False


End With
Next
Error: Exit Sub
End Sub
 
Untested, uncompiled:

Sub LastPoinLabel()
Dim mySrs As Series
Dim nPts As Long
dim nCtr as long
On Error GoTo ErrorExit
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
for nctr = 2 to npts step 2
mySrs.Points(nctr).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
next nctr
End With
Next mySrs
ErrorExit: Exit Sub
End Sub

or maybe
for nctr = 1 to npts step 2
Depending on which one you want to start with.
 
Back
Top