Name

series.ApplyCustomType(ChartType)

Synopsis

Applies a chart type to a series. Use this method to create combo charts containing more than one chart type.

Argument

Settings

ChartType

An xlChartType constant. See the reference topic for the Chart object’s ChartType property for a list of possible settings.

The following code creates a chart and adds series using the SeriesCollection Add method; then it changes the chart type of the last series to create a combo chart containing both line and column chart types:

Sub AddSeries(  )
    Dim chrt As Chart, sc As SeriesCollection, _
      sr As Series
    ' Create a line chart.
    Set chrt = Charts.Add
    chrt.ChartType = xlLine
    ' Get the series collection.
    Set sc = chrt.SeriesCollection
    ' Add adds some series (plots data).
    sc.Add Range("GrowthRate"), , True, True
    ' Get the last series.
    Set sr = sc(sc.Count)
    ' Change its chart type.
    sr.ApplyCustomType xlColumnClustered
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.