Help Center

CellForeColorproperty

Returns or sets the foreground 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 CellForeColor () AS OLE_COLOR
PROPERTY CellForeColor (BYVAL clr AS OLE_COLOR)

Parameters

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

Description

Returns or sets the the text color (foreground color) of the currently active cell or a selected range of cells.

Set for a single cell:

Set for a range: To change the text color for multiple cells at once, use the FillStyle property to avoid looping through every individual cell.

Examples

grid.Row = 1 grid.Col = 2 grid.CellForeColor = vbBlue ' Changes text in cell (1, 2) to blue

grid.FillStyle = flexFillRepeat ' Apply changes to all cells in selection grid.Row = 1: grid.Col = 1 grid.RowSel = 5: grid.ColSel = 5 grid.CellForeColor = vbRed grid.FillStyle = flexFillSingle ' Reset to default single-cell behavior

Reference