Move table column to far right

S

stevewy

If I have a selection of rows in the middle of a table and I want a
macro to move them downwards so that they are the last rows in the
table, no matter how big the table is, I can do this with VBA:

NumRows = Selection.Tables(1).Rows.Count
For K = 1 To NumRows
Selection.Range.Relocate wdRelocateDown
Next K

But if I have a column selected and want to move it to the far right of
the table, so it becomes the last column, how can I achieve this easily
in VBA? There does not appear to be a wdRelocateRight or Left
command....

Steve Wylie
 
C

Cindy M.

If I have a selection of rows in the middle of a table and I want a
macro to move them downwards so that they are the last rows in the
table, no matter how big the table is, I can do this with VBA:

NumRows = Selection.Tables(1).Rows.Count
For K = 1 To NumRows
Selection.Range.Relocate wdRelocateDown
Next K

But if I have a column selected and want to move it to the far right of
the table, so it becomes the last column, how can I achieve this easily
in VBA? There does not appear to be a wdRelocateRight or Left
command....
You'd have to use Selection.Cut, then select the end of the table and
Selection.Paste. Very roughly

Dim rw as Word.Row
Dim nrCells as Long
Set rw = tbl.Rows(1)
nrCells = rw.Cells.Count
rw.Cells(nrCells).Select
Selection.MoveRight wdCharacter, 1, false
Selection.Paste

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top