I am trying to add data label only to the largest piece of a pie chart using VBA.
When I try to run the following code i get an error message: 'Object doesnt support this property of method'
The error referes to the line:
sem = ActiveSheet.ChartObjects("REJT").Chart.SeriesCollection(1).Points(x).Value
Can anyone tell me what is the issue with this line? Is there an alternative way of getting value of a chart data point?
Dim krb As Long
Dim x As Long
Dim rr As Long
Dim sem As Long
Dim xmax As Long
Set pts = ActiveSheet.ChartObjects("REJT").Chart.SeriesCollection(1).Points
krb = pts.Count
x = 1
rr = 0
'While loop to find largest part of pie chart
While x < (krb + 1)
sem = ActiveSheet.ChartObjects("REJT").Chart.SeriesCollection(1).Points(x).Value
MsgBox (sem)
If sem > rr Then
rr = sem
xmax = x
End If
x = x + 1
Wend
'Add data label to the largest part of pie chart
ActiveSheet.ChartObjects("REJT").Activate
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Points(xmax).Select
ActiveChart.SeriesCollection(1).Points(xmax).ApplyDataLabels


