Microsoft Office Tutorials and References
In Depth Information
Using VBA to Display Arbitrary Data Labels on a Chart
Result = VALUES_FROM_SERIES(s)
If Result(1) = “Range” Then
Set DRange = Range(Result(2))
If DRange.Rows.Count > 1 Then
Set DRange = DRange.Resize(DRange.Rows.Count - 1)
s.Values = DRange
The ExpandAllSeries procedure is very similar. When executed, it expands each range by
Figure 18-8: This workbook demonstrates how to expand and contract the chart series by using VBA macros.
Using VBA to Display Arbitrary Data Labels
on a Chart
One of the most frequent complaints about Excel’s charting is its inflexible data labeling feature.
For example, consider the XY chart in Figure 18-9. It would be useful to display the associated
name for each data point. However, you can search all day, and you’ll never find the Excel
command that lets you do this automatically. Such a command doesn’t exist. Data labels are limited
to the data values only — unless you want to edit each data label manually and replace it with
text (or a formula) of your choice.