Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-Format [sort] a table

Status
Not open for further replies.

markSaunders

Programmer
Jun 23, 2000
196
GB
I have a table that contains several columns (qty can change).

The 4th column contains a field that I wish to sort the table on. I actually want to cut out all rows where the 4th column contains CLOSED and paste this into a new table at the end of the document.

I tried the following code...

Code:
    Dim tbl As Table
    Set tbl = ActiveDocument.Tables(1).Cell

    For lx = tbl.Rows.Count To 1 Step -1
        If tbl.Cell(lx, 4).
Value
Code:
= "CLOSED" Then
            tbl.Rows(lx).
Cut
Code:
            Set rng = ActiveDocument.Range
            
            rng.Collapse (wdCollapseEnd)
            rng.Paste
            
        End If
    Next lx

but am not sure how to test the contents (ideally i could check if the cell contains the text rather than equals it

nor can i deduce how to get the row to the clipboard!

any advice would be gratefully received!

mark Mark Saunders :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top