ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data Labels (https://www.excelbanter.com/excel-programming/314037-data-labels.html)

Bill[_28_]

Data Labels
 
Hello,
Is there a way to determine how many data labels a series has? Thanks.

Bill



Andy Pope

Data Labels
 
Hi Bill,

Try this routine.
The error trap should handle problems caused by missing or gaps in your
data plus the deletion of individual data labels within a series.

Sub x()
Dim intSeries As Integer
Dim intPoint As Integer
Dim intCountDataLabels As Integer

On Error GoTo ErrCount

With ActiveChart
For intSeries = 1 To .SeriesCollection.Count
With .SeriesCollection(intSeries)
If .HasDataLabels Then
intCountDataLabels = 0
For intPoint = 1 To .Points.Count
If .Points(intPoint).HasDataLabel Then
If Err.Number = 0 Then _
intCountDataLabels = intCountDataLabels + 1
End If
Next
MsgBox "Series " & intSeries & " has " & _
intCountDataLabels & " of out a possible " & .Points.Count
Else
MsgBox "Series " & intSeries & " has no data labels"
End If
End With
Next
End With

Exit Sub
ErrCount:
intCountDataLabels = intCountDataLabels - 1
Resume Next
End Sub

Cheers
Andy

Bill wrote:

Hello,
Is there a way to determine how many data labels a series has? Thanks.

Bill



--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info


All times are GMT +1. The time now is 04:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com