Results 1 to 6 of 6

Thread: Delete specific table rows in Word

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2009
    Posts
    3

    Resolved Delete specific table rows in Word

    I have found the following code which works well with a document with one Word table. I need the code to go through the entire document which has a large number of tables. All the tables are two columns (multiple rows) and I need to delete the whole row if it contains a certain word in cell 1.

    Sub DeleteRows()

    Dim TargetText As String
    Dim oRow As Row

    If Selection.Information(wdWithInTable) = False Then Exit Sub

    TargetText = InputBox$("Enter target text:", "Delete Rows")

    For Each oRow In Selection.Tables(1).Rows
    If oRow.Cells(1).Range.Text = TargetText & vbCr & Chr(7) Then oRow.Delete
    Next oRow

    End Sub

    I would appreciate any assistance you can offer.

    Thanks
    Last edited by Gizzmo1; Apr 12th, 2009 at 07:39 AM. Reason: Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width