Hi all,
I want to first acknowledge that I have also posted this question on excelforum.com. I am posting here as well because my question on the other site seems to be getting lost in the shuffle, and I am hoping for a reply today or tomorrow. Thanks so much for reading this
So - here's my question...
I am working with a scatterplot that contains 6 series. The x-axis data are actual salaries for a group of employees, and the y-axis data are predicted salaries (from a regression analysis) minus actual salaries. The employees are in six groups, so I've put a series for each group in the scatterplot in order to get the markers to look different. I have a macro that will add labels from Column A to the markers in Series 1, but it doesn't add the labels I want to any of the other series. (I am doing this because the default marker labels aren't very helpful for my purposes.) Here is the macro:
Any help you can offer regarding how to modify this to get it to work for all series is much appreciated!
Thanks!!!
(p.s. I haven't included a spreadsheet here because I can't share the data. However, if a mock data set would help, please let me know.)
I want to first acknowledge that I have also posted this question on excelforum.com. I am posting here as well because my question on the other site seems to be getting lost in the shuffle, and I am hoping for a reply today or tomorrow. Thanks so much for reading this

So - here's my question...
I am working with a scatterplot that contains 6 series. The x-axis data are actual salaries for a group of employees, and the y-axis data are predicted salaries (from a regression analysis) minus actual salaries. The employees are in six groups, so I've put a series for each group in the scatterplot in order to get the markers to look different. I have a macro that will add labels from Column A to the markers in Series 1, but it doesn't add the labels I want to any of the other series. (I am doing this because the default marker labels aren't very helpful for my purposes.) Here is the macro:
Code:
Sub AttachLabelsToPoints()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
' Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.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)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(1).Points(Counter).HasDataLabel = _
True
ActiveChart.SeriesCollection(1).Points(Counter).DataLabel.Text = _
Range(xVals).Cells(Counter, 1).Offset(0, -1).Value
Next Counter
End Sub
Any help you can offer regarding how to modify this to get it to work for all series is much appreciated!
Thanks!!!
(p.s. I haven't included a spreadsheet here because I can't share the data. However, if a mock data set would help, please let me know.)