Rows.Add Method (Word)

Returns a Row object that represents a row added to a table.

Syntax

expression. Add( _BeforeRow_ )

expression Required. A variable that represents a 'Rows' collection.

Parameters

Name Required/Optional Data Type Description
BeforeRow Optional Variant A Row object that represents the row that will appear immediately below the new row.

Return Value

Row

Example

This example inserts a new row before the first row in the selection.

Sub AddARow() 
 If Selection.Information(wdWithInTable) = True Then 
 Selection.Rows.Add BeforeRow:=Selection.Rows(1) 
 End If 
End Sub

This example adds a row to the first table and then inserts the text Cell into this row.

Sub CountCells() 
 Dim tblNew As Table 
 Dim rowNew As Row 
 Dim celTable As Cell 
 Dim intCount As Integer 
 
 intCount = 1 
 Set tblNew = ActiveDocument.Tables(1) 
 Set rowNew = tblNew.Rows.Add(BeforeRow:=tblNew.Rows(1)) 
 For Each celTable In rowNew.Cells 
 celTable.Range.InsertAfter Text:="Cell " &; intCount 
 intCount = intCount + 1 
 Next celTable 
End Sub

See also

Rows Collection Object