Excel VBA - Add Data labels to Bar Chart
Posted on 2011-10-18
I have the cde below which takes data from a worksheet called 'ALL' and creates a bar chart. this is working well however I would like the bar chart to display datalabels for the values and can't seem to work out how this is added. we are using Excel 2002.
Can anyone point me in the right direction on how to add data labels to the chart I have created
'Get last populated column for graph
For c = 1 To 26
If ActiveCell.Value = Empty Then
lastColumn = Chr(64 + (ActiveCell.Column - 1))
ActiveChart.ChartType = xlColumnStacked
ActiveChart.SetSourceData Source:=Sheets("ALL").Range("A1:" & lastColumn & numProjects + 1), PlotBy:= _
ActiveChart.Location Where:=xlLocationAsNewSheet, Name:= _
"Project Defects Graph"
.HasTitle = True
.ChartTitle.Characters.Text = "Project Defects"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "QC Project \ Project Name"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Defect Count"
Sheets("Project Defects Graph").Select
Sheets("Project Defects Graph").move Before:=Sheets(1)