ColorIndex Property

Microsoft Excel Visual Basic

Returns or sets the color of the border. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants. Read/write Variant.

XlColorIndex can be one of these XlColorIndex constants.
xlColorIndexAutomatic
xlColorIndexNone

expression.ColorIndex

expression    Required. An expression that returns an object in the Applies To List.

ShowColorIndex Property as it applies to the Borders object.

Returns or sets the color of all four borders. Returns Null if all four borders aren't the same color. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants. Read/write Variant.

XlColorIndex can be one of these XlColorIndex constants.
xlColorIndexAutomatic
xlColorIndexNone

expression.ColorIndex

expression    Required. An expression that returns an object in the Applies To List.

ShowColorIndex Property as it applies to the Font object.

Returns or sets the color of the font. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants. Read/write Variant.

XlColorIndex can be one of these XlColorIndex constants.
xlColorIndexAutomatic. Use to specify automatic color.
xlColorIndexNone.   

expression.ColorIndex

expression    Required. An expression that returns an object in the Applies To List.

ShowColorIndex Property as it applies to the Interior object.

Returns or sets the color of the interior. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants. Read/write Variant.

XlColorIndex can be one of these XlColorIndex constants.
xlColorIndexAutomatic. Use to specify the automatic fill, for drawing objects.
xlColorIndexNone. Use to specify no interior fill.

expression.ColorIndex

expression    Required. An expression that returns an object in the Applies To List.

Example

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

ShowExample as it applies to the Border object.

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

With Charts("Chart1").Axes(xlValue)
    If .HasMajorGridlines Then
        .MajorGridlines.Border.ColorIndex = 5    'set color to blue
    End If
End With
				

ShowExample as it applies to the Font object.

This example changes the font color in cell A1 on Sheet1 to red.

Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3
				

ShowExample as it applies to the Interior and Border objects.

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

With Charts("Chart1").ChartArea
    .Interior.ColorIndex = 3
    .Border.ColorIndex = 5
End With