View Single Post
 
Old 05-07-2020, 02:30 PM
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

Try the following. In this case, if a 'Not Applicable' result is required, the macro deletes the original empty second column and widens the original third column to compensate.
Code:
Sub DeleteCheckedContent()
Application.ScreenUpdating = False
Dim Tbl As Table, r As Long
For Each Tbl In ActiveDocument.Tables
  With Tbl
    If .Cell(1, 1).Range.ContentControls.Count = 1 Then
      If .Cell(1, 1).Range.ContentControls(1).Checked = True Then
        For r = .Rows.Count To 2 Step -1
          .Rows(r).Delete
        Next
        .Rows.Add
        If .Columns.Count > 2 Then
          .Columns(3).Width = .Columns(2).Width + .Columns(3).Width
          .Columns(2).Delete
        End If
        .Cell(2, 2).Range.Text = "Not applicable"
      Else
        For r = .Rows.Count To 2 Step -1
          If .Cell(r, 1).Range.ContentControls(1).Checked = True Then .Rows(r).Delete
        Next
      End If
      .Columns(1).Delete
    End If
  End With
Next
Application.ScreenUpdating = True
End Sub
If you want to leave the columns intact, delete or comment-out:
Code:
        If .Columns.Count > 2 Then
          .Columns(3).Width = .Columns(2).Width + .Columns(3).Width
          .Columns(2).Delete
        End If
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote