Final Thoughts on Programming Charts

 < Day Day Up > 



After reviewing the variety of options available when creating and modifying charts in a procedure, you'll see that creating a programmatic reference to a chart on a chart sheet is easy. The Chart object is a member of the Charts collection of the workbook. The challenge is setting the reference to an embedded chart. You must be aware that the embedded Chart object is contained in a ChartObject object that belongs to the ChartObjects collection of the worksheet. Remember, the Object Browser can be your greatest asset when troubleshooting your VBA code.

You can move or resize an embedded chart by changing the Top, Left, Width, and Height properties of the ChartObject object. If you already have a reference to the Chart object, you can get a reference to the ChartObject object through the Parent property of the Chart object.

Individual series in a chart are Series objects and belong to the SeriesCollection object of the chart. The Delete method of the Series object is used to delete a series from a chart. You use the NewSeries method of the SeriesCollection object to add a new series to a chart.

You can assign a VBA array, rather than the more commonly used Range object, to the Values property of a Series object. This creates a chart that is independent of worksheet data and can be distributed without a supporting worksheet.

The Values and XValues properties return data values, not the range references used in a chart. You can determine the ranges referenced by a chart by examining the SERIES function in the Formula property of each series.

Keep in mind the complexity of the Chart Model as you create procedures that reference charts. Use some of the recommended tips provided to simplify how to reference the chart and produce cleaner code, such as assigning the chart an object variable.

In the next chapter, you will learn how to setup your workbook so you can use PivotTables and PivotCharts.



 < Day Day Up > 



Microsoft Excel 2003 Programming Inside Out
Microsoft Office Excel 2003 Programming Inside Out (Inside Out (Microsoft))
ISBN: 0735619859
EAN: 2147483647
Year: 2006
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net