Phone (01457) 858877 or email
This follow-up article to a previous blog describes how to label the data points in multiple series in Excel using VBA.
You can read the original blog here. In addition to blogging furiously, we also run courses for businesses in both Excel and VBA.
A while ago I wrote a blog describing how you could use VBA in Excel to label the data points in a scatter chart. Recently someone asked a question about how to adapt the code I created to label more than one series in the same chart. Here's the problem we're trying to solve:

The chart contains one data series plotting RunTime against Budget and another plotting RunTime against Box Office. We want to label each data point with the name of the film.
The key to this solution is looping over each data series for every data point that we want to label. The code below will work for any number of data series that the chart contains:
Sub CreateDataLabels()
'variables for looping over chart objects
Dim FilmChart As Chart
Dim FilmDataSeries As Series
'variables for looping over cells
Dim SingleCell As Range
Dim FilmList As Range
'variable to keep track of number of films
Dim FilmCounter As Integer
FilmCounter = 1
Set FilmList = Range("A2", "A11")
Set FilmChart = ActiveSheet.ChartObjects(1).Chart
'loop over each data series and enable data labels
For Each FilmDataSeries In FilmChart.SeriesCollection
FilmDataSeries.HasDataLabels = True
Next FilmDataSeries
'loop over each cell in the list of source data
For Each SingleCell In FilmList
'loop over each series in the chart
For Each FilmDataSeries In FilmChart.SeriesCollection
'change the label text to be the film's name
FilmDataSeries.Points(FilmCounter).DataLabel.Text = SingleCell.Value
Next FilmDataSeries
FilmCounter = FilmCounter + 1
Next SingleCell
End Sub
The end result of running this code is that each data point in the chart will be labelled:

Each data point in the chart now shows the name of the film that it represents.
You can download the completed example for this blog.
Comments on this blog
This blog has one comment:
Hi Alex,
Thanks for the comment. I've posted the answer shown below in the other thread on this subject along with an explanation but thought I should repeat it here too. Sorry for the delay in replying!
Sub CreateDataLabels()
'variables for looping over chart objects
Dim FilmChart As Chart
Dim FilmDataSeries As Series
'variables for looping over cells
Dim SingleCell As Range
Dim FilmList As Range
'variable to keep track of number of films
Dim FilmCounter As Integer
'variable to keep track of number of series
Dim SeriesCounter As Integer
Set FilmList = Range("A2", "A11")
Set FilmChart = ActiveSheet.ChartObjects(1).Chart
'loop over each data series and enable data labels
For Each FilmDataSeries In FilmChart.SeriesCollection
FilmDataSeries.HasDataLabels = True
Next FilmDataSeries
FilmCounter = 1
SeriesCounter = 1
Set FilmDataSeries = FilmChart.SeriesCollection(SeriesCounter)
'loop over each cell in the list of source data
For Each SingleCell In FilmList
'change the label text to be the film's name
FilmDataSeries.Points(FilmCounter).DataLabel.Text = SingleCell.Value
FilmCounter = FilmCounter + 1
'if the FilmCounter is higher than the number of points in the series, reset the FilmCounter
'move on to the next data series
If FilmCounter > FilmDataSeries.Points.Count Then
FilmCounter = 1
SeriesCounter = SeriesCounter + 1
'if we've exceeeded the number of data series in the chart then exit the loop
If SeriesCounter > FilmChart.SeriesCollection.Count Then Exit For
'if we're still in the loop, store a reference to the next data series
Set FilmDataSeries = FilmChart.SeriesCollection(SeriesCounter)
End If
Next SingleCell
End Sub