Hi!
I am collating some feedback which I need to present in line graphs which include the data table showing the FY and the no. of response. As such, I must use the "name" column as the series name when creating these graphs.
In addition, I have been using a VBA that I found online to label the last data point of the graphs. However, the points are labelled with the "name" column. Instead, I would like the points to be labelled with the text from the "Financial Year" column (i.e. FY13, FY14 etc).
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Financial Year[/TD]
[TD]Response[/TD]
[TD]Name[/TD]
[TD]Q1[/TD]
[TD]Q2[/TD]
[/TR]
[TR]
[TD]FY13[/TD]
[TD]10[/TD]
[TD]FY13 (n = 10)[/TD]
[TD]2.2[/TD]
[TD]3.4[/TD]
[/TR]
[TR]
[TD]FY14[/TD]
[TD]20[/TD]
[TD]FY14 (n = 20)[/TD]
[TD]1.5[/TD]
[TD]3.1[/TD]
[/TR]
[TR]
[TD]FY15 1st Half[/TD]
[TD]5[/TD]
[TD]FY15 1st Half (n = 5)[/TD]
[TD]3.6[/TD]
[TD]2.8[/TD]
[/TR]
</tbody>[/TABLE]
I am completely new to VBA and have been tearing my hair out over this. Is it possible to edit the VBA below to label the data points with the data from the "financial year" column rather than the series name?
==========
Sub LabelLastPoint()
Dim mySrs As Series
Dim nPts As Long
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
mySrs.Points(nPts).DataLabel.Text = mySrs.Name
End With
Next
End Sub
===========
I am collating some feedback which I need to present in line graphs which include the data table showing the FY and the no. of response. As such, I must use the "name" column as the series name when creating these graphs.
In addition, I have been using a VBA that I found online to label the last data point of the graphs. However, the points are labelled with the "name" column. Instead, I would like the points to be labelled with the text from the "Financial Year" column (i.e. FY13, FY14 etc).
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Financial Year[/TD]
[TD]Response[/TD]
[TD]Name[/TD]
[TD]Q1[/TD]
[TD]Q2[/TD]
[/TR]
[TR]
[TD]FY13[/TD]
[TD]10[/TD]
[TD]FY13 (n = 10)[/TD]
[TD]2.2[/TD]
[TD]3.4[/TD]
[/TR]
[TR]
[TD]FY14[/TD]
[TD]20[/TD]
[TD]FY14 (n = 20)[/TD]
[TD]1.5[/TD]
[TD]3.1[/TD]
[/TR]
[TR]
[TD]FY15 1st Half[/TD]
[TD]5[/TD]
[TD]FY15 1st Half (n = 5)[/TD]
[TD]3.6[/TD]
[TD]2.8[/TD]
[/TR]
</tbody>[/TABLE]
I am completely new to VBA and have been tearing my hair out over this. Is it possible to edit the VBA below to label the data points with the data from the "financial year" column rather than the series name?
==========
Sub LabelLastPoint()
Dim mySrs As Series
Dim nPts As Long
For Each mySrs In ActiveChart.SeriesCollection
With mySrs
nPts = .Points.Count
mySrs.Points(nPts).ApplyDataLabels _
Type:=xlDataLabelsShowValue, _
AutoText:=True, LegendKey:=False
mySrs.Points(nPts).DataLabel.Text = mySrs.Name
End With
Next
End Sub
===========