Share via


ChDataLabels Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

ChDataLabelsCollection
Aa198395.parchild(en-us,office.10).gifChDataLabels
Aa198395.space(en-us,office.10).gifAa198395.parchild(en-us,office.10).gif

Contains a collection of ChDataLabel objects that represent all the data labels in the specified set of data labels for a series. Note that a series can contain more than one set of data labels.

Using the ChDataLabels object

The following methods and properties can be used to return a ChDataLabels object:

The  ChDataLabelsCollection collection object's Add method.

The  ChDataLabelsCollection collection object's Item property.

The following example adds data labels to the first series in the first chart in Chartspace1 and then formats the data labels.

  Sub AddDataLabels()

    Dim serSeries1
    Dim dlSeries1Labels

    ' Set a variable to the first series of the first chart
    ' in Chartspace1.
    Set serSeries1 = ChartSpace1.Charts(0).SeriesCollection(0)

    ' Add a set of data labels to the first series and return
    ' a DataLabels object.
    Set dlSeries1Labels = serSeries1.DataLabelsCollection.Add

    ' Set the number format of the data labels.
    dlSeries1Labels.NumberFormat = "0.00"

    ' Set the data labels to display the category
    ' name for the data point.
    dlSeries1Labels.HasCategoryName = True

    ' Set the data labels to display the value
    ' for the data point.
    dlSeries1Labels.HasValue = True

End Sub