PDA

View Full Version : [SOLVED:] Column Swap Issue



Khanonline
11-26-2014, 11:58 PM
Hi All

I have many Tables in a File, For all the Table I am trying to change the position of all the Tables.
For Reference Please Have a look at the Image:






Can somebody have a Macro that performs this sort of action? or any assistance is most welcome.


Note: This is not reversal of Column, Actually this is I want to Change the position.

Thanks

gmayor
11-28-2014, 12:34 AM
Provided the tables do not contain any split or merged cells the following should work


Sub TransposeCols()
Dim oTable As Table
Dim oCol As Column
Dim i As Long
For Each oTable In ActiveDocument.Tables
For i = oTable.Columns.Count - 1 To 1 Step -1
oTable.Columns(i).Select
Selection.Cut
oTable.Columns.Last.Select
With Selection
.InsertColumnsRight
.PasteAndFormat (wdPasteDefault)
.MoveRight Unit:=wdWord, Count:=1
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Columns.Delete
End With
Next i
Next oTable
End Sub

Khanonline
12-01-2014, 02:49 AM
Thanks buddy for this useful Mac. It works good but I have a translated file attached below i dont know why it did not work properly on such files. Can you please guide me on this?

Best,
Khanonline

gmayor
12-02-2014, 07:38 AM
Click the '¶' button and you will see that the table is still formatted for right to left language. It needs to be formatted for left to right. I regret I know nothing of right to left language settings, and do not have my PC configured to use them.

Khanonline
12-02-2014, 10:00 AM
oooops... No worries buddy. I will investigate it further. Thanks again for your code.