ColorIndex Property [Excel 2003 VBA Language Reference]

ColorIndex Property as it applies to the Border object.

XlColorIndex

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.

ColorIndex Property as it applies to the Borders object.

XlColorIndex

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.

ColorIndex Property as it applies to the Font object.

XlColorIndex

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.

ColorIndex Property as it applies to the Interior object.

XlColorIndex

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.

ColorIndex Property as it applies to the Tab object.

XlColorIndex

XlColorIndex can be one of these XlColorIndex constants.
xlColorIndexNone. Use to specify that the tab has no color.

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.

Example 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

Example 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

Example 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

Applies to | Border Object | Borders Collection | Font Object | Interior Object | Tab Object

See Also | Color Property | Colors Property | PatternColor Property