RowIndex Property

Microsoft Word Visual Basic

expression.RowIndex

expression    Required. An expression that returns a Cell object.

Example

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

Set newDoc = Documents.Add
Set myTable = newDoc.Tables.Add(Range:=Selection.Range, _
    NumRows:=3, NumColumns:=3)
For Each aCell In myTable.Columns(1).Cells
    aCell.Select
    MsgBox "This is row " & aCell.RowIndex
Next aCell
		

This example displays the row number of the first row in the selection.

If Selection.Information(wdWithInTable) = True Then
    Msgbox Selection.Cells(1).RowIndex
End If