ColumnIndex Property 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.

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

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

Msgbox Selection.Cells(1).ColumnIndex