I have a scatter chart with five different series. I want to name the data points with their labels in all the
series'. I have a code which works just fine with one series, but dies when I try it for multiple series. Can someone please
help me with this... searched a lot on the net, but couldn't find any code which does this...
The code that works
for one series is:
' Dimension variables.
Dim Cht As Chart
Dim xVals As String
Dim Counter As Integer
' Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
Set Cht = ActiveWorkbook.Worksheets("B'berg Links").ChartObjects("Chart 1").Chart
' Store the formula for the first series in "xVals".
xVals = Cht.SeriesCollection(1).Formula
' Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, Mid(Left(xVals, InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
' Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
Cht.SeriesCollection(1).Points(Counter).HasDataLabel = True
Cht.SeriesCollection(1).Points(Counter).DataLabel.Text = Range(xVals).Cells(Counter, -3).Value
If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines