Retrieving data point labels from field names in the worksheet
Sub DataLabelsFromRange()
Dim DLRange As range
Dim myChart As Chart
Dim i As Integer
Set myChart = ActiveSheet.ChartObjects(1).Chart
On Error Resume Next
Set DLRange = Application.InputBox _
(prompt:="Range for data labels?", Type:=8)
If DLRange Is Nothing Then Exit Sub
On Error GoTo 0
myChart.SeriesCollection(1).ApplyDataLabels Type:=xlDataLabelsShowValue, AutoText:=True, LegendKey:=False
Pts = myChart.SeriesCollection(1).Points.Count
For i = 1 To Pts
myChart.SeriesCollection(1). _
Points(i).DataLabel.Characters.Text = DLRange(i)
Next i
End Sub
Related examples in the same category