I am trying to delete all data labels in an Excel chart for each of the series but somehow my code doesn't delete any of the data labels on the chart. Please let me know if there is something lacking in my code below. I am currently using Microsoft Office 365 and the file is an xlsb .
Thanks in advance and really appreciate your help.
Sub DeleteDataLabels()
Sheets("Sheet1").Select
Call UnprotectSheet
ActiveSheet.ChartObjects("Chart 2").Activate
SeriesCount = ActiveChart.SeriesCollection.Count
MsgBox SeriesCount
' To delete the code
For i = 1 To SeriesCount
ActiveChart.SeriesCollection(i).Select
ActiveChart.ChartArea.Select
If ActiveChart.SeriesCollection(i).HasDataLabels Then
ActiveChart.SeriesCollection(i).DataLabels.Select
Selection.Delete
End If
Next i
End Sub