ColumnIndex Property

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


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.

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
    MsgBox "This is column " & cellLoop.ColumnIndex
Next cellLoop

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

Msgbox Selection.Cells(1).ColumnIndex

Applies to | Cell Object

See Also | Columns Property | IsFirst Property | IsLast Property | Item Method | RowIndex Property