Name

chart.ApplyCustomType(ChartType, [TypeName])

Synopsis

Applies an autoformat to a chart.

Argument

Settings

ChartType

xlBuiltIn selects from a set of built-in autoformats; xlUserDefined selects from a set of user-defined autoformats.

TypeName

The name of the autoformat to apply.

Tip

If you omit TypeName, ApplyCustomType is equivalent to setting the ChartType property and the ChartType argument then accepts xlChartType constants.

To see the available autoformats, select a chart, choose Chart → Chart Type, and click the Custom Types tab. The ChartType and TypeName arguments correspond to items on the Chart Type dialog box as shown in Figure 16-7.

Applying an autoformat to a chart

Figure 16-7. Applying an autoformat to a chart

The following code applies the B&W Column autoformat to a chart:

Sub ApplyAutoFormat(  )
    Dim chrt As Chart
    Set chrt = Charts("New Chart")
    chrt.ApplyCustomType xlBuiltIn, "B&W Column"
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.