Name

chartfillformat.TwoColorGradient(Style, Variant)

Synopsis

Applies a two-color gradient.

Argument

Settings

Style

An msoGradientStyle constant indicating the type of the gradient. See the GradientStyle property for a list of settings.

Variant

The index of the gradient variant to use. The variants are listed on the Gradient tab in the Fill Effects dialog box.

The following code applies a two-color gradient to the chart area:

Sub TwoColorGradient( )
    Dim chrt As Chart, cf As ChartFillFormat
    ' Get the chart.
    Set chrt = ActiveChart
    ' Get the chart area fill.
    Set cf = chrt.ChartArea.Fill
    ' Make the fill visible.
    cf.Visible = True
    ' Set colors for gradient.
    cf.BackColor.SchemeColor = 17
    cf.ForeColor.SchemeColor = 1
    ' Display a gradient fill.
    cf.TwoColorGradient msoGradientDiagonalUp, 2
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.