View Single Post
 
Old 04-04-2020, 05:42 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Deleting empty table rows is far simpler than what you're using. For example:
Code:
Sub DeleteEmptyRows()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long
For Each Tbl In ActiveDocument.Tables
  With Tbl
    For r = .Rows.Count To 1 Step -1
      With .Rows(r)
        If Len(.Range.Text) = .Cells.Count * 2 + 2 Then .Delete
      End With
    Next
  End With
Next
Application.ScreenUpdating = True
End Sub
To delete a row if a cell in a specified column (in this case column 2) is blank:
Code:
Sub DeleteEmptyRows()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long
For Each Tbl In ActiveDocument.Tables
  With Tbl
    For r = .Rows.Count To 1 Step -1
      With .Rows(r)
        If Len(.Cells(2).Range.Text) = 2 Then .Delete
      End With
    Next
  End With
Next
Application.ScreenUpdating = True
End Sub
PS: When posting code, please structure your code properly and use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote