View Single Post
 
Old 01-11-2024, 05:13 AM
vivka vivka is offline Windows 7 64bit Office 2016
Expert
 
Join Date: Jul 2023
Posts: 293
vivka is on a distinguished road
Default

Hi! Try this:
Code:
Sub DeleteEmptyRows_If()
'In the doc's 2nd tbl, delete rows if any of their cells starting from the 3rd cell is empty.

Dim tbl As Table, cel As cell
Dim i As Long, j As Long, n As Long

    Application.ScreenUpdating = False
    Set tbl = ActiveDocument.range.Tables(2)
    n = tbl.rows.count
    For i = n To 1 Step -1
        For j = 3 To tbl.rows(i).Cells.count
            Set cel = tbl.rows(i).Cells(j)
            If Len(cel.range.text) = 2 Then
                 tbl.rows(i).Delete
                Exit For
             End If
        Next j
    Next i
Set cel = Nothing: Set tbl = Nothing
Application.ScreenUpdating = True
End Sub

Last edited by vivka; 01-11-2024 at 07:37 AM.
Reply With Quote