ColorIndex Property

Microsoft Graph Visual Basic

Object Description Border The color of the border. Font The color of the font. Interior The color of the interior fill. Set ColorIndex to xlColorIndexNone to specify that you don't want an interior fill. Set ColorIndex to xlColorIndexAutomatic to specify the automatic fill (for drawing objects).

expression.ColorIndex

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

This property specifies a color as an index into the color palette. The following illustration shows the color-index values in the default color palette.

Color index values in default color palette

Example

The following examples assume that you're using the default color palette.

This example sets the color of the major gridlines for the value axis.

With myChart.Axes(xlValue)
    If .HasMajorGridlines Then
        'Set color to blue
        .MajorGridlines.Border.ColorIndex = 5
    End If
End With
		

This example sets the color of the chart area interior to red and sets the border color to blue.

With myChart.ChartArea
    .Interior.ColorIndex = 3
    .Border.ColorIndex = 5
End With