23.1. Working with Charts

This section shows you how to use VBA to create and format charts, either as entire chart sheets in a Workbook or as objects on an existing worksheet.

23.1.1. Creating a Chart

VBA uses the Chart object to represent a chart on a chart sheet and a ChartObject object to represent an embedded chart on a worksheet. The ChartObject object contains a Chart object, which you can manipulate by accessing it through the ChartObject.

Whichever method you use, when writing a procedure you create the chart or chart object in a different order than when working manually:

  1. You add the chart or chart object.

  2. You specify the source range for its data.

  3. You specify the chart type.

  4. You specify any other items you want to add.

23.1.1.1. Creating ...

Get Mastering VBA for Microsoft Office 2007, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.