Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
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.
FIGURE 18-9: An XY chart with no data labels.
The DataLabelsFromRange procedure works with the first chart on the active sheet. It prompts the user for a range and then loops through the