I have a macro which adds the data labels in a bubble chart. This code provides the value of the Y axis.
I would like to show the SeriesName instead.
Sub AddDataLabels()
Dim bubbleChart As ChartObject
Dim mySrs As Series
Dim myPts As Points
With ActiveSheet
For Each bubbleChart In .ChartObjects
For Each mySrs In bubbleChart.Chart.SeriesCollection
Set myPts = mySrs.Points
myPts(myPts.Count).ApplyDataLabels Type:=xlShowValue
Next
Next
End With
End Sub
I tried changing
myPts(myPts.Count).ApplyDataLabels Type:=xlShowValue
Into:
myPts(myPts.Count).ApplyDataLabels Type:=xlShowSeriesName
It gives me
'Invalid procedure call or argument'
How can I change the code to display the SeriesName instead of the Y axis value?
Screenshot
Add the
With
statement in my code below inside your code, and adjust the parameters inside according to your needs.In the code below the chart
Daralabels
will show theSeriesName
, but not the Category or Values.