Prev: Word/Excel 2007 - copy chart object problems
Next: Office 2007 and Office 2003 and word macros.
From: Compass Rose on 13 Sep 2009 18:21 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 14 Sep 2009 04:16 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 14 Sep 2009 11:55 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 > > >
|
Pages: 1 Prev: Word/Excel 2007 - copy chart object problems Next: Office 2007 and Office 2003 and word macros. |