TechWhirl (TECHWR-L) is a resource for technical writing and technical communications professionals of all experience levels and in all industries to share their experiences and acquire information.
For two decades, technical communicators have turned to TechWhirl to ask and answer questions about the always-changing world of technical communications, such as tools, skills, career paths, methodologies, and emerging industries. The TechWhirl Archives and magazine, created for, by and about technical writers, offer a wealth of knowledge to everyone with an interest in any aspect of technical communications.
Michael Collier wrote:
>
> I have a twelve page table done in Word where I'd like to delete all of the rows
> where column 2 has a certain value (the letter C, in this case--the value for
> Column 2 can be C, I or M). Style formatting is not used.
>
> I need to delete the entire row, not just the letter. Find/Replace does not
seem
> to help. Any suggestions, like how to write a macro to do this, or move the data
> to Excel and work with it?
Thanks to all who sent suggestions. Two types of solutions were offered: sort by
the desired column and delete, or write a macro. The sort solutions are simple
enough to execute, though I am suspicious that sorting will disrupt the
hierearchical relationship among the the rows. But the sort suggestion offered by
& and / may address that:
1. Add a new column (you'll be deleting it later, so don't adjust the
existing column widths; just tack it on the right).
2. Manually number the rows by typing numbers into the new column. Don't
use autonumbers.
3. Sort the table on the column that has C, I, M
4. Select all of the C rows as a block and delete them.
5. Sort the table on the numbered column.
6. Delete the numbered column.
Chris Knight offered this macro:
Here's a macro that seems to work:
Sub MAIN
REM Put the cursor anywhere in the column you want to check for "C"
TableSelectColumn
NumRows = SelInfo(15)
For i = 1 To NumRows
EditGoTo .Destination = "\Cell"
CharLeft 1, 1
If Selection$() = "C" Then
TableSelectRow
TableDeleteRow
Else
If i < NumRows Then
EndOfRow(1)
NextObject
NextObject
EndOfColumn(1)
EndIf
EndIf
Next i
TableSelectColumn
CharLeft 1
End Sub
Since I may end up with six or seven tables like this, I think the time is well
worth investing in writing and testing the macro.