M
MikeM
Hello All:
Below is the code from Microsoft to apply category labels to an XY data
series.
I've changed the SeriesCollection and Offset values to fit my chart and it
works fine.
However, the data labels are text labels and I really need them to be values
that can be formatted like any other number value.
Is there any way to modify this code to create the new data labels as values
instead of text?
I've been fooling around with 'DataLabel.Text' in the second to last line to
no avail...
Thanks.
Mike
Sub AttachLabelsToPoints()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
'Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(8).Formula
'Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, Mid(Left(xVals,
InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(8).Points(Counter).HasDataLabel = True
ActiveChart.SeriesCollection(8).Points(Counter).DataLabel.Text =
Range(xVals).Cells(Counter, 1).Offset(0, -9).Value
Next Counter
End Sub
Below is the code from Microsoft to apply category labels to an XY data
series.
I've changed the SeriesCollection and Offset values to fit my chart and it
works fine.
However, the data labels are text labels and I really need them to be values
that can be formatted like any other number value.
Is there any way to modify this code to create the new data labels as values
instead of text?
I've been fooling around with 'DataLabel.Text' in the second to last line to
no avail...
Thanks.
Mike
Sub AttachLabelsToPoints()
'Dimension variables.
Dim Counter As Integer, ChartName As String, xVals As String
'Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(8).Formula
'Extract the range for the data from xVals.
xVals = Mid(xVals, InStr(InStr(xVals, ","), xVals, Mid(Left(xVals,
InStr(xVals, "!") - 1), 9)))
xVals = Left(xVals, InStr(InStr(xVals, "!"), xVals, ",") - 1)
Do While Left(xVals, 1) = ","
xVals = Mid(xVals, 2)
Loop
'Attach a label to each data point in the chart.
For Counter = 1 To Range(xVals).Cells.Count
ActiveChart.SeriesCollection(8).Points(Counter).HasDataLabel = True
ActiveChart.SeriesCollection(8).Points(Counter).DataLabel.Text =
Range(xVals).Cells(Counter, 1).Offset(0, -9).Value
Next Counter
End Sub