Export (0) Print
Expand All

Shapes.AddChart Method

Office 2007
Creates a chart at the specified location on the active sheet.

Version Information
 Version Added:  Excel 2007

Syntax

expression.AddChart(Type, Left, Top, Width, Height)

expression   A variable that represents a Shapes object.

Parameters

NameRequired/OptionalData TypeDescription
TypeOptionalXlChartTypeThe chart type.
LeftOptionalVariantThe distance, in points, from the left edge of the object to the left edge of column A (on a worksheet) or the left edge of the chart area (on a chart).
TopOptionalVariantThe distance, in points, from the top edge of the topmost shape in the shape range to the top edge of the worksheet.
WidthOptionalVariantThe width, in points, of the object.
HeightOptionalVariantThe height, in points, of the object.

Return Value
Shape

Remarks

If the chart type is omitted, the default chart type for the application is used. If the position is omitted, the default size for the application is used.

Example

The following example adds a chart to the active worksheet. The data for the stacked cylinder column chart type is taken from cells A10 to B14.

Visual Basic for Applications
Range("A10:B14").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=Range("Sheet1!$A$10:$B$14"), PlotBy:= _
        xlColumns
    ActiveChart.ChartType = xlCylinderColStacked
   



Community Additions

ADD
Show:
© 2014 Microsoft