Edit

Share via


Cell.RowIndex property (Word)

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

Syntax

expression. RowIndex

expression 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

See also

Cell Object

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.