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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving/Copying a row in word table

Status
Not open for further replies.

blkdmnd

Technical User
Feb 18, 2003
1
US
Greetings all,

I'm new to this VBA stuff and am trying to implememnt a macro that will move some row inside a word table.

Basically want to move row 12 to row 1. I've tried various combinations of commands, but can't seem to get the macro to actually select row 12, then cut it, so that I can paste it into row 1.

Any help would be appreciated.

Thanks
 
Hiya,

you might give this a go:
Code:
    Dim l_tblTable As Table
    Dim l_rowRow As Row
    
    Set l_tblTable = ThisDocument.Tables(1)

    Set l_rowRow = l_tblTable.Rows(12)
    l_rowRow.Select
    l_rowRow.Range.Cut
    l_tblTable.Rows(1).Range.Paste
    
    Set l_rowRow = Nothing
    Set l_tblTable = Nothing

This'll select the first table in your document (if you need to change another table just change the index number ..), cuts row 12 & pastes it back as row 1
The number of rows stays the same, but row 1 is moved down 1 row, and row 12 becomes row 1

HTH

Cheers
Nikki
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top