From: Compass Rose on
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
From: Graham Mayor on
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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



Compass Rose wrote:
> 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


From: Compass Rose on
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


"Graham Mayor" wrote:

> 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
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
>
> Compass Rose wrote:
> > 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
>
>
>