The following code should delete every row but the first. However, it deletes every second row.
Dim index As Long
For index = 2 To ActiveDocument.Tables(1).Rows.Count
ActiveDocument.Tables(1).Rows(index).Delete
Exit For
Next
The following code should delete every row but the first. However, it deletes every second row.
Dim index As Long
For index = 2 To ActiveDocument.Tables(1).Rows.Count
ActiveDocument.Tables(1).Rows(index).Delete
Exit For
Next
The solution is to loop backwards using Step -1
.
Dim index As Long
For index = ActiveDocument.Tables(1).Rows.Count To 2 Step -1
ActiveDocument.Tables(1).Rows(index).Delete
Next
Deleting just the last row is as simple as:
With ActiveDocument.Tables(1)
.Rows(.Rows.Count).Delete
End With