6
votes

I created a macro that adds data labels to the two series in my pivot chart.

Sub Data_Labels_On_Pivot2()
'
' Data_Labels_On_Pivot2 Macro
'

'
    ActiveSheet.Unprotect
    ActiveSheet.ChartObjects("Chart 14").Activate
    ActiveChart.SetElement (msoElementDataLabelCenter)
    ActiveSheet.ChartObjects("Chart 14").Activate
    ActiveChart.FullSeriesCollection(1).DataLabels.Select
    Selection.Position = xlLabelPositionOutsideEnd
    Application.CommandBars("Format Object").Visible = False
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

This works on machines running Excel 2013.

With Excel 2010 .FullSeriesCollection(1) generates an error:

"Compile Error: Method or data member not found"

I googled this topic and was not able to find anything. I did come across the ActiveX issues from the Windows update earlier this year and was not able to find any .exd files on the machine running Excel 2010 that I am testing with.

1
FullSeriesCollection was added in Excel 2013. See This. What happens when you replace FullSeriesCollection object with SeriesCollection?Siddharth Rout
It works! I also had to remove this row: Application.CommandBars("Format Object").Visible = False. I'm not sure why. If you don't mind me asking, what is the difference between FullSeriesCollection and SeriesCollection? My macro performs the same action with either in Excel 2013.JPerez

1 Answers

6
votes

FullSeriesCollection was added in Excel 2013. It isn't a valid property in earlier versions.

Replace FullSeriesCollection with SeriesCollection, which is valid in Excel 2010.

Credits to Siddharth Rout who posted this answer as a comment.