0

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
Community
  • 1
  • 1

2 Answers2

0

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
BigBen
  • 46,229
  • 7
  • 24
  • 40
0

Deleting just the last row is as simple as:

With ActiveDocument.Tables(1)
  .Rows(.Rows.Count).Delete
End With
macropod
  • 12,757
  • 2
  • 9
  • 21