Hi ladies & gentlemen,
I have a VBA code that generates a graph with 21 different series from one dataset, with as purpose to be able to show a series names as datalabel for every datapoint. In this way I can use "3 Dimensions" in one scatterplot.
Everything is working fine, except that I want to show the right datalabels automatically. In the code I have now this only works for the last datapoint, the rest shows normal datalabels with only numbers instead of the series name. Perhaps someone can suggest how to adapt the code so the Loop executes the right way.
I have highlighted the part of the code in bold that is not executing corretly. Any pointers for me?
I have a VBA code that generates a graph with 21 different series from one dataset, with as purpose to be able to show a series names as datalabel for every datapoint. In this way I can use "3 Dimensions" in one scatterplot.
Everything is working fine, except that I want to show the right datalabels automatically. In the code I have now this only works for the last datapoint, the rest shows normal datalabels with only numbers instead of the series name. Perhaps someone can suggest how to adapt the code so the Loop executes the right way.
I have highlighted the part of the code in bold that is not executing corretly. Any pointers for me?
Rich (BB code):
Sub LabelPoints2()'
'
ActiveSheet.ChartObjects("CompetenceMap").Activate
ActiveChart.ChartArea.Select
Dim myXValues As Range
Dim myYValues As Range
Dim myNameValues As Range
Set myXValues = Application.InputBox(prompt:="Range of X Values?", Type:=8)
Set myYValues = Application.InputBox(prompt:="Range of Y Values?", Type:=8)
Set myNameValues = Application.InputBox(prompt:="Range of Labels?", Type:=8)
For i = 1 To 21
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).XValues = myXValues(i)
ActiveChart.SeriesCollection(i).Values = myYValues(i)
ActiveChart.SeriesCollection(i).Name = myNameValues(i)
ActiveChart.SeriesCollection(i).Select
With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
With Selection
.MarkerBackgroundColorIndex = 25
.MarkerForegroundColorIndex = 25
.MarkerStyle = xlDiamond
.Smooth = False
.MarkerSize = 5
.Shadow = False
End With
ActiveChart.SetElement (msoElementDataLabelRight)
ActiveChart.ApplyDataLabels
ActiveChart.SeriesCollection(i).DataLabels.Select
Selection.ShowSeriesName = True
Selection.ShowValue = False
Next
End Sub