Class Chart (Excel VBA)

The class Chart represents a chart in a workbook.

The classes Application, ChartObject, Shape, Window and Workbook. give access to class Chart


Dim chr as Chart
Set chr = ActiveChart

For Each

Here is an example of processing the Chart items in a collection.


Dim chr As Chart
For Each chr In Charts
	
Next chr

Methods

ApplyDataLabels - Applies data labels to all the series in a chart.


Charts("Chart1").SeriesCollection(1). _ 
 ApplyDataLabels Type:=xlDataLabelsShowLabel

ChartWizard - Modifies the properties of the given chart. You can use this method to quickly format a chart without setting all the individual properties. This method is noninteractive, and it changes only the specified properties.


Charts("Chart1").ChartWizard _ 
 Gallery:=xlLine, _ 
 HasLegend:=True, CategoryTitle:="Year", ValueTitle:="Sales"

Refresh - Causes the specified chart to be redrawn immediately.


ActiveChart.Refresh

SetSourceData - Sets the source data range for the chart.


Charts(1).SetSourceData Source:=Sheets(1).Range("a1:a10"), _ 
 PlotBy:=xlColumns

Activate - Makes the current chart the active chart.

ApplyChartTemplate - Applies a standard or custom chart type to a chart.

ApplyLayout - Applies the layouts shown in the ribbon.

Axes - Returns an axes that represents either a single axis or a collection of the axes on the chart.

ChartGroups - Returns an chartgroups that represents either a single chart group (a ChartGroup) or a collection of all the chart groups in the chart (a ChartGroups). The returned collection includes every type of group.

ChartObjects - Returns an chartobjects that represents either a single embedded chart (a ChartObject object) or a collection of all the embedded charts (a ChartObjects collection) on the sheet.

CheckSpelling - Checks the spelling of an object.

ClearToMatchColorStyle - Clears all colors on the specified chart that do not follow the color style applied to the chart.

ClearToMatchStyle - Clears the chart elements formatting to automatic.

Copy - Copies the sheet to another location in the workbook.

CopyPicture - Copies the selected object to the Clipboard as a picture.

Delete - Deletes the object.

Evaluate - Converts a Microsoft Excel name to an object or a value.

Export - Exports the chart in a graphic format.

ExportAsFixedFormat - Exports to a file of the specified format.

FullSeriesCollection - Enables retrieving the filtered out series specified by the Index argument.

GetChartElement - Returns information about the chart element at specified x and y coordinates. This method is unusual in that you specify values for only the first two arguments. Microsoft Excel fills in the other arguments, and your code should examine those values when the method returns.

GetProperty -

Location - Moves the chart to a new location.

Move - Moves the chart to another location in the workbook.

OLEObjects - Returns an oleobjects that represents either a single OLE oleobjects (an OLEObject) or a collection of all OLE oleobjectss (an OLEObjects collection) on the chart or sheet. Read-only.

Paste - Pastes chart data from the Clipboard into the specified chart.

PrintOut - Prints the object.

PrintPreview - Shows a preview of the object as it would look when printed.

Protect - Protects a chart so that it cannot be modified.

SaveAs - Saves changes to the chart or worksheet in a different file.

SaveChartTemplate - Saves a custom chart template to the list of available chart templates.

Select - Selects the object.

SeriesCollection - Returns an seriescollection that represents either a single series (a Series collection) or a collection of all the series (a SeriesCollection collection) in the chart or chart group.

SetBackgroundPicture - Sets the background graphic for a chart.

SetDefaultChart - Specifies the name of the chart template that Microsoft Excel uses when creating new charts.

SetElement - Sets chart elements on a chart.

SetProperty -

Unprotect - Removes protection from a sheet or workbook. This method has no effect if the sheet or workbook isn't protected.

Properties

AutoScaling true if Microsoft Excel scales a 3D chart so that it's closer in size to the equivalent 2D chart. The RightAngleAxes property must be True.

BackWall returns a Walls object that allows the user to individually format the back wall of a 3D chart.

BarShape returns or sets the shape used with the 3D bar or column chart.

CategoryLabelLevel returns an XlCategoryLabelLevel constant referring to the level of where the category labels are being sourced from.

ChartArea returns a ChartArea object that represents the complete chart area for the chart.

ChartColor returns or sets an Integer that represents the color scheme for the chart. Read/write.

ChartStyle returns or sets the chart style for the chart.

ChartTitle returns a ChartTitle object that represents the title of the specified chart.

ChartType returns or sets the chart type.

CodeName returns the code name for the object.

DataTable returns a DataTable object that represents the chart data table.

DepthPercent returns or sets the depth of a 3D chart as a percentage of the chart width (between 20 and 2000 percent).

DisplayBlanksAs returns or sets the way that blank cells are plotted on a chart. Can be one of the XlDisplayBlanksAs constants.

DisplayValueNotAvailableAsBlank

Elevation returns or sets the elevation of the 3D chart view, in degrees.

Floor returns a Floor object that represents the floor of the 3D chart.

GapDepth returns or sets the distance between the data series in a 3D chart as a percentage of the marker width. The value of this property must be between 0 and 500.

HasAxis returns or sets which axes exist on the chart. Read/write Variant.

HasDataTable true if the chart has a data table.

HasLegend true if the chart has a legend.

HasTitle true if the axis or chart has a visible title.

HeightPercent returns or sets the height of a 3D chart as a percentage of the chart width (between 5 and 500 percent).

Hyperlinks returns a Hyperlinks collection that represents the hyperlinks for the chart.

Index returns a Long value that represents the index number of the object within the collection of similar objects.

Legend returns a Legend object that represents the legend for the chart.

MailEnvelope represents an email header for a document.

Name returns or sets a String value representing the name of the object.

Next returns a Worksheet worksheet that represents the next sheet.

PageSetup returns a PageSetup object that contains all the page setup settings for the specified object.

Perspective returns or sets a Long value that represents the perspective for the 3D chart view.

PivotLayout returns a PivotLayout object that represents the placement of fields in a PivotTable report and the placement of axes in a PivotChart report.

PlotArea returns a PlotArea object that represents the plot area of a chart.

PlotBy returns or sets the way columns or rows are used as data series on the chart. Can be one of the following XlRowCol constants: xlColumns or xlRows.

PlotVisibleOnly true if only visible cells are plotted. False if both visible and hidden cells are plotted.

Previous returns a Worksheet worksheet that represents the previous sheet.

PrintedCommentPages returns the number of comment pages that will be printed for the current chart.

ProtectContents true if the contents of the sheet are protected. For a chart, this protects the entire chart. To turn on content protection, use the Protect method with the Contents argument set to True.

ProtectData true if series formulas cannot be modified by the user.

ProtectDrawingObjects true if shapes are protected. To turn on shape protection, use the Protect method with the DrawingObjects argument set to True.

ProtectFormatting true if chart formatting cannot be modified by the user.

ProtectionMode true if user-interface-only protection is turned on. To turn on user interface protection, use the Protect method with the UserInterfaceOnly argument set to True.

ProtectSelection true if chart elements cannot be selected.

RightAngleAxes true if the chart axes are at right angles, independent of chart rotation or elevation. Applies only to 3D line, column, and bar charts. Read/write Boolean.

Rotation returns or sets the rotation of the 3D chart view (the rotation of the plot area around the z-axis, in degrees). The value of this property must be from 0 to 360, except for 3D bar charts, where the value must be from 0 to 44. The default value is 20. Applies only to 3D charts. Read/write Variant.

SeriesNameLevel returns an XlSeriesNameLevel constant referring to the level of where the series names are being sourced from.

Shapes returns a Shapes collection that represents all the shapes on the chart sheet.

ShowAllFieldButtons returns or sets whether to display all field buttons on a PivotChart.

ShowAxisFieldButtons returns or sets whether to display axis field buttons on a PivotChart.

ShowDataLabelsOverMaximum returns or sets whether to show the data labels when the value is greater than the maximum value on the value axis.

ShowExpandCollapseEntireFieldButtons true to display the Expand Entire Field and Collapse Entire Field buttons on the specified PivotChart.

ShowLegendFieldButtons returns or sets whether to display legend field buttons on a PivotChart.

ShowReportFilterFieldButtons returns or sets whether to display the report filter field buttons on a PivotChart.

ShowValueFieldButtons returns or sets whether to display the value field buttons on a PivotChart.

SideWall returns a Walls object that allows the user to individually format the side wall of a 3D chart.

Tab returns a Tab object for a chart.

Visible returns or sets an XlSheetVisibility value that determines whether the object is visible.

Walls returns a Walls object that represents the walls of the 3D chart.

Axes - A collection of all the Axis objects in the specified chart.

ChartArea - Represents the chart area of a chart.

ChartGroups - Represents one or more series plotted in a chart with the same format.

ChartObjects - A collection of all the ChartObject objects on the specified chart sheet, dialog sheet, or worksheet.

ChartTitle - Represents the chart title.

DataTable - Represents a chart data table.

Floor - Represents the floor of a 3D chart.

FullSeriesCollection - Represents the full set of Series objects in a chart.

Hyperlinks - Represents the collection of hyperlinks for a worksheet or range.

Legend - Represents the legend in a chart. Each chart can have only one legend.

OLEObjects - A collection of all the OLEObject objects on the specified worksheet.

PageSetup - Represents the page setup description.

PivotLayout - Represents the placement of fields in a PivotChart report.

PlotArea - Represents the plot area of a chart.

SeriesCollection - A collection of all the Series objects in the specified chart or chart group.

Shapes - A collection of all the Shape objects on the specified sheet.

Tab - Represents the tab of a chart or a worksheet.

Walls - Represents the walls of a 3D chart. This object isn't a collection. There's no object that represents a single wall; you must return all the walls as a unit.

Worksheet - Represents a worksheet.