Help Center

CellBackColorproperty

Returns or sets the background colors of individual cells or cell ranges.

Windowspropertydoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Syntax

PROPERTY CellBackColor () AS OLE_COLOR
PROPERTY CellBackColor (BYVAL bkColor AS OLE_COLOR)

Parameters

NameDescription
bkColorA numeric expression that specifies the color for the current cell selection. Setting this property to zero paints the cell using the standard background color.

Description

Returns or sets the background color of the currently active cell or a selected range of cells.

The property affects the cell(s) determined by the current Row and Col properties.

Set for Single Cell:

Set for a Range: To color multiple cells at once, set the FillStyle property to flexFillRepeat.

Examples

grid.Row = 2 ' Target row grid.Col = 1 ' Target column grid.CellBackColor = vbRed ' Set color to red

grid.FillStyle = flexFillRepeat grid.Row = 1: grid.Col = 1 grid.RowSel = 3: grid.ColSel = 3 grid.CellBackColor = vbBlue grid.FillStyle = flexFillSingle ' Reset to single-cell mode

Reference