ColumnIndex Property

Microsoft Word Visual Basic

ColumnIndex Property

       

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

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.

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.

Msgbox Selection.Cells(1).ColumnIndex