ColorIndex Property
Applies To
Border object, Borders collection object, Font object, Interior object.
Description
Returns or sets the color of the border, font, or interior, as shown in the following table. The color is specified as an index value into the current color palette, or as one of the following XlColorIndex constants: xlColorIndexAutomatic or xlColorIndexNone. Read/write Variant.
Object | ColorIndex |
|
Border | The color of the border. |
Borders | The color of all four borders. Returns Null if all four borders aren't the same color. |
Font | The color of the font. Specify xlColorIndexAutomatic to use the automatic color. |
Interior | The color of the interior fill. Set this property to xlColorIndexNone to specify that you don't want an interior fill. Set this property to xlColorIndexAutomatic to specify the automatic fill (for drawing objects). |
Remarks
This property specifies a color as an index into the workbook color palette. You can use the Colors method to return the current color palette.
See Also
Color property, Colors property, PatternColor property.
Example
The following examples assume that you're using the default color palette.
This example changes the font color in cell A1 on Sheet1 to red.
Worksheets("Sheet1").Range("A1").Font.ColorIndex = 3
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
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