ChartType = xl3DColumnClustered
End Sub
The first line of code selects the data range for the chart. The next line adds a chart and
activates it via its Select method. Charts are members of the Shape class, and the AddChart
method returns a Shape object.
ActiveSheet.Shapes.AddChart.Select
The AddChart method has a few optional arguments (listed in Table 5-1) and no required
arguments.
Table 5-1. AddChartMethod Arguments
Name Data Type Description
Type xlChartType Type of chart (bar, line, pie, etc.)
Left Variant Distance from the left edge of the chart to the left edge of Column A
Top Variant Distance from the top edge of the chart to the top edge of the
worksheet
Width Variant Width of the chart
Height Variant Height of the chart
The Type property is of data type xlChartType. This enumeration includes all of the chart
types Excel ships with, as shown in Table 5-2.
Table 5-2. The xlChartType Enumerations
Name Description Value
xl3DArea 3D area -4098
xl3DAreaStacked 3D stacked area 78
xl3DAreaStacked100 100% stacked area 79
xl3DBarClustered 3D clustered bar 60
CHAPTER 5 n CHARTING IN EXCEL 2007 198
Name Description Value
xl3DBarStacked 3D stacked bar 61
xl3DBarStacked100 3D 100% stacked bar 62
xl3DColumn 3D column -4100
xl3DColumnClustered 3D clustered column 54
xl3DColumnStacked 3D stacked column 55
xl3DColumnStacked100 3D 100% stacked column 56
xl3DLine 3D line -4101
xl3DPie 3D pie -4102
xl3DPieExploded Exploded 3D pie 70
xlArea Area 1
xlAreaStacked Stacked area 76
xlAreaStacked100 100% stacked area 77
xlBarClustered Clustered bar 57
xlBarOfPie Bar of pie 71
xlBarStacked Stacked bar 58
xlBarStacked100 100% stacked bar 59
xlBubble Bubble 15
xlBubble3DEffect Bubble with 3D effects 87
xlColumnClustered Clustered column 51
xlColumnStacked Stacked column 52
xlColumnStacked100 100% stacked column 53
xlConeBarClustered Clustered cone bar 102
xlConeBarStacked Stacked cone bar 103
xlConeBarStacked100 100% stacked cone bar 104
xlConeCol 3D cone column 105
xlConeColClustered Clustered cone column 99
xlConeColStacked Stacked cone column 100
xlConeColStacked100 100% stacked cone column 101
xlCylinderBarClustered Clustered cylinder bar 95
xlCylinderBarStacked Stacked cylinder bar 96
xlCylinderBarStacked100 100% stacked cylinder bar 97
xlCylinderCol 3D cylinder column 98
xlCylinderColClustered Clustered cone column 92
xlCylinderColStacked Stacked cone column 93
xlCylinderColStacked100 100% stacked cylinder column 94
xlDoughnut Doughnut -4120
xlDoughnutExploded Exploded doughnut 80
Continued
CHAPTER 5 n CHARTING IN EXCEL 2007 199
Table 5-2.
Pages:
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201