Share via


Cell.ColumnIndex Property

Word Developer Reference

Returns the number of the table column that contains the specified cell. Read-only Long.

Syntax

expression.ColumnIndex

expression   A variable that represents a Cell object.

Example

This example creates a table in a new document, selects each cell in the first row, and returns the column number that contains the selected cell.

Visual Basic for Applications
  Dim docNew As Document
Dim tableNew As Table
Dim cellLoop As Cell

Set docNew = Documents.Add Set tableNew = docNew.Tables.Add(Selection.Range, 3, 3) For Each cellLoop In tableNew.Rows(1).Cells cellLoop.Select MsgBox "This is column " & cellLoop.ColumnIndex Next cellLoop

This example returns the column number of the cell that contains the insertion point.

Visual Basic for Applications
  Msgbox Selection.Cells(1).ColumnIndex

See Also