Class Chart (Excel VBA)
The class Chart represents a chart in a workbook.
To use a Chart class variable it first needs to be instantiated, for example
Dim chr as Chart Set chr = ActiveChart
The following procedures can be used to set variables of type Chart: Application.ActiveChart, Location, ChartObject.Chart, Shape.Chart, ShapeRange.Chart, Sheets.Add, Sheets.Item, Sheets.Visible, Window.ActiveChart and Workbook.ActiveChart.
Here is an example of processing the Chart items in a collection.
Dim chr As Chart For Each chr In Charts Next chr
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.
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.
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.
Location - Moves the chart to a new location.
Move - Moves the chart to another location in the workbook.
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.
Unprotect - Removes protection from a sheet or workbook. This method has no effect if the sheet or workbook isn't protected.
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.
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.
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.
ChartType returns or sets the chart type.
CodeName returns the code name for the object.
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.
Elevation returns or sets the elevation of the 3D chart view, in degrees.
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).
Index returns a Long value that represents the index number of the object within the collection of similar objects.
MailEnvelope represents an email header for a document.
Name returns or sets a String value representing the name of the object.
Perspective returns or sets a Long value that represents the perspective for the 3D chart view.
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.
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.
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.
Visible returns or sets an XlSheetVisibility value that determines whether the object is visible.
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.