Cell.ColumnIndex property (Word)
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.
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
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for