Cells Property

Applies To

Column object, Range object, Row object, Selection object.

Description

Returns a Cells collection that represents the table cells in a column, row, selection, or range. Read-only.

See Also

Cell method, Columns property, Rows property.

Example

This example creates a 3x3 table and assigns a sequential cell number to each cell in the table.

Set newDoc = Documents.Add
Set myTable = newDoc.Tables.Add(Selection.Range, 3, 3)
i = 1
For Each c In myTable.Range.Cells
    c.Range.InsertAfter "Cell " & i
    i = i + 1
Next c
This example sets the current cell's background color to red.

If Selection.Information(wdWithInTable) = True Then
    Selection.Cells(1).Shading.BackgroundPatternColorIndex = wdRed
Else
    MsgBox "The insertion point is not in a table."
End If