DataLabel Object
TOC
Collapse the table of content
Expand the table of content

DataLabel Object (PowerPoint)

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Represents the data label on a chart point or trendline.

On a series, the DataLabel object is a member of the DataLabels collection. The DataLabels collection contains a DataLabel object for each point. For a series without definable points (such as an area series), the DataLabels collection contains a single DataLabel object.

Note Note

Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

Use DataLabels(Index), where Index is the data label index number, to return a single DataLabel object. The following example sets the number format for the fifth data label in the first series of the first chart in the active document.

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        .Chart.SeriesCollection(1).DataLabels(5).NumberFormat = "0.000"

    End If

End With


Note Note

Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

Use the Point.DataLabel property to return the DataLabel object for a single point. The following example turns on the data label for the second point in the first series of the first chart in the active document and sets the data label text to "Saturday."

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        With .Chart.SeriesCollection(1).Points(2)

            .HasDataLabel = True

            .DataLabel.Text = "Saturday"

        End With

    End If

End With


Note Note

Although the following code applies to Microsoft Word, you can readily modify it to apply to PowerPoint.

On a trendline, the Trendline.DataLabel property returns the text shown with the trendline. This can be the equation, the R-squared value, or both (if both are showing). The following example sets the trendline text for the first trendline in the first series of the first chart in the active document to show only the equation.

With ActiveDocument.InlineShapes(1)

    If .HasChart Then

        With .Chart.SeriesCollection(1).Trendlines(1)

            .DisplayRSquared = False

            .DisplayEquation = True

        End With

    End If

End With
Show:
© 2016 Microsoft