Delete a row in a table

C

Compass Rose

I have a document which has a table with 2 columns. The left column has a
list of tasks, and the right column is a 'comment' column. What I would like
to do is review the table from top to bottom and delete any rows where the
word "Done" appears in the right column. I am too inexperienced with VBA
programming to figure this one out.

TIA
David
 
G

Graham Mayor

Assuming Table 1 and assuming that Done may be in upper case, lower case or
title case and is not part of a longer word then

Sub RemoveDone()
Dim oTable As Table
Dim i As Long
Set oTable = ActiveDocument.Tables(1)
For i = oTable.Rows.Count To 1 Step -1
If InStr(1, LCase(oTable.Cell(i, 2).Range.Text), "done") <> 0 Then
oTable.Rows(i).Delete
End If
Next i
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Compass Rose

This does the trick! Thank you so much. I find it's also an excellent way to
learn the coding so that I become less reliant on your expertise.

Thanks again,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top