Option Explicit
Sub test()
Dim oChart As Chart
Dim seriesIndex As Long
'Set the chart (change the sheet and chart references accordingly)
Set oChart = Worksheets("Sheet1").ChartObjects("Chart 1").Chart
'Specify the series number (change accordingly)
seriesIndex = 1
AttachTextBoxesToMarkers oChart, seriesIndex
End Sub
Sub AttachTextBoxesToMarkers(oChart As Chart, seriesIndex As Long)
If seriesIndex <= 0 Or seriesIndex > oChart.SeriesCollection.Count Then
MsgBox "Series index is out of bounds!", vbExclamation
Exit Sub
End If
Dim shp As Shape
Dim pt As Point
Dim pointIndex As Long
Const TEXTBOX_HEIGHT As Long = 15
Const TEXTBOX_WIDTH As Long = 40
Const GAP As Long = 5
With oChart.SeriesCollection(seriesIndex)
For pointIndex = 1 To .Points.Count
If .Points(pointIndex).MarkerStyle <> -4142 Then
Set pt = .Points(pointIndex)
With pt
Set shp = oChart.Shapes.AddTextbox(msoTextOrientationHorizontal, .Left, .Top - (TEXTBOX_HEIGHT + GAP), TEXTBOX_WIDTH, TEXTBOX_HEIGHT)
End With
With shp
With .Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 255) 'change colour accordingly
End With
.TextFrame2.TextRange.Text = "YourTextHere"
End With
End If
Next pointIndex
End With
End Sub