I need to add a column in each table in my file with hundreds of tables. Example of a table is attached. Everything works fine when the macro adds a column to a table without merged cells but it messes up columns when it comes to tables with merged cells. And the most interesting: manually adding a column to the left of a merged cell (col 1 in example) works fine. I even recorded a macro of a fine manual adding but when I run it, it again ruins the columns.
My code:
Set Cll = Tbl.Cell(1, colNum) 'colNum - user input of where to insert a column
Cll.Select
Selection.SelectColumn
Selection.InsertColumns
Code from a recorded macro (it also ruins formatting):
Selection.EndKey Unit:=wdColumn, Extend:=True
Selection.InsertColumns
Example:
By "Ruins" I mean the next thing (the added columns are selected):
Example of what is needed to be one (and is done manually by clicking the button): Result
Comments
Post a Comment