Hi,
I've been trying to teach myself VBA, with mixed results.
I want to label the points on a scattergraph - Excel doesn't seem to do it automatically.
So I tried the code below to add labels from a range of 52 labels, arranged in a column.
When I run it it doesn't like:
any ideas?
I have found an add-in that does this much better, but I would like to understand what I'm doing wrong
Thanks for your help!!!
pwchad
I've been trying to teach myself VBA, with mixed results.
I want to label the points on a scattergraph - Excel doesn't seem to do it automatically.
So I tried the code below to add labels from a range of 52 labels, arranged in a column.
When I run it it doesn't like:
Code:
Cells(a, 5).Select
any ideas?
I have found an add-in that does this much better, but I would like to understand what I'm doing wrong
Thanks for your help!!!
pwchad
Code:
Sub AddValues()
Dim a As Integer
Dim strName As String
a = 1
For a = 1 To 52
Cells(a, 5).Select
strName = Cells(a, 5).FormulaR1C1
ActiveSheet.ChartObjects("Chart 5").Activate
ActiveChart.SeriesCollection(1).Points(a).ApplyDataLabels Type:= _
xlDataLabelsShowValue, AutoText:=True, LegendKey:=False
ActiveChart.SeriesCollection(1).Points(a).DataLabel.Characters.Text = strName
Next a
End Sub