View Single Post
 
Old 08-10-2023, 11:56 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Most of your code can be removed to speed it up.

You start by applying a Table Style. A lot of the later code can be removed if the Table style being applied has those attributes as part of the style. Since that is a one off step to define the table style, you don't even need that to be part of the macro.

The many lines adjusting the width of the columns can be reduced by deleting all but the last line for each column. For example the only line you need here is the one in red
Code:
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=148.85, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=154.45, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=163.05, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=170.1, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=177.2, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=184.3, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=191.4, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=198.45, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=205.55, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=212.65, RulerStyle:= wdAdjustNone
Selection.Tables(1).Columns(5).SetWidth ColumnWidth:=212.65, RulerStyle:= wdAdjustNone
Delete the rest of the lines and just keep the last line for each column number.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote