Share via


Cells Property [Publisher 2003 VBA Language Reference]

Cells property as it applies to the Column and Row objects.

Returns a CellRange object that represents the cell or cells in a column or row of a table.

expression.Cells

expression Required. An expression that returns one of the above objects.

Cells property as it applies to the Table object.

Returns a CellRange object that represents a range of cells in a table.

expression.Cells(StartRow, StartColumn, EndRow, EndColumn)

expression Required. An expression that returns a Table object.

StartRow  Optional Long. The row in which the starting cell exists. If this argument is omitted, all the table rows are included in the range.

StartColumn  Optional Long. The column in which the starting cell exists. If this argument is omitted, all the table columns are included in the range.

EndRow  Optional Long. The row in which the ending cell exists. If this argument is omitted, only the row specified by StartRow is included in the range. If this argument is specified but StartRow is omitted, an error occurs.

EndColumn  Optional Long. The column in which the ending cell exists. If this argument is omitted, only the column specified by StartColumn is included in the range. If this argument is specified but StartColumn is omitted, an error occurs.

Remarks

If all arguments are omitted, all the cells in the table are included in the range.

Example

As it applies to the Column and Row objects.

This example merges the first and second cells in the first column of the specified table.

Sub MergeCell()
    With ActiveDocument.Pages(1).Shapes(2).Table.Columns(1)
        .Cells(1).Merge MergeTo:=.Cells(2)
    End With
End Sub

This example applies a thick border outline to the first cell in the second column of the specified table.

Sub OutlineBorderCell()
    With ActiveDocument.Pages(1).Shapes(2).Table.Columns(2).Cells(1)
        .BorderLeft.Weight = 5
        .BorderRight.Weight = 5
        .BorderTop.Weight = 5
        .BorderBottom.Weight = 5
    End With
End Sub

As it applies to the Table object.

This example merges the first two cells in the first two rows of the specified table.

Sub MergeCells()
    ActiveDocument.Pages(1).Shapes(2).Table _
        .Cells(StartRow:=1, StartColumn:=1, _
        EndRow:=2, EndColumn:=2).Merge
End Sub

Applies to | Column Object | Row Object | Table Object