Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Adding column via VBA messes up my tables in Word

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:

enter image description here

By "Ruins" I mean the next thing (the added columns are selected):

enter image description here

Example of what is needed to be one (and is done manually by clicking the button): Result

Comments