Chart.ApplyDataLabels Method

Excel Developer Reference

Applies data labels to all the series in a chart.

Syntax

expression.ApplyDataLabels(Type, LegendKey, AutoText, HasLeaderLines, ShowSeriesName, ShowCategoryName, ShowValue, ShowPercentage, ShowBubbleSize, Separator)

expression   A variable that represents a Chart object.

Parameters

Name Required/Optional Data Type Description
Type Optional XlDataLabelsType The type of data label to apply.
LegendKey Optional Variant True to show the legend key next to the point. The default value is False.
AutoText Optional Variant True if the object automatically generates appropriate text based on content.
HasLeaderLines Optional Variant For the Chart and Series objects, True if the series has leader lines.
ShowSeriesName Optional Variant Pass a boolean value to enable or disable the series name for the data label.
ShowCategoryName Optional Variant Pass a boolean value to enable or disable the category name for the data label.
ShowValue Optional Variant Pass a boolean value to enable or disable the value for the data label.
ShowPercentage Optional Variant Pass a boolean value to enable or disable the percentage for the data label.
ShowBubbleSize Optional Variant Pass a boolean value to enable or disable the bubble size for the data label.
Separator Optional Variant The separator for the data label.
Bb211636.vs_note(en-us,office.12).gif  Note
When using the Separator parameter.
If you use a string, you will get a string as the separator. If you use xlDataLabelSeparatorDefault (= 1), you will get the default data label separator, which is either a comma or a newline, depending on the data label.
When a value of "1" is returned, it indicates that the user has not changed the default separator which is a comma ",". You can also pass a value of "1" to change the separator back to the default separator.

The chart must first be active before you can access the data labels programmatically; otherwise a run-time error occurs.

Remarks

XlDataLabelsType can be one of these XlDataLabelsType constants.
xlDataLabelsShowBubbleSizes. The bubble size for the data label.
xlDataLabelsShowLabelAndPercent. Percentage of the total, and category for the point. Available only for pie charts and doughnut charts.
xlDataLabelsShowPercent. Percentage of the total. Available only for pie charts and doughnut charts.
xlDataLabelsShowLabel. Category for the point.
xlDataLabelsShowNone. No data labels.
xlDataLabelsShowValue. default. Value for the point (assumed if this argument isn't specified).

Example

This example applies category labels to series one in Chart1.

Visual Basic for Applications
  Charts("Chart1").SeriesCollection(1). _
    ApplyDataLabels Type:=xlDataLabelsShowLabel

See Also