Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 08-10-2023, 11:56 PM
Guessed's Avatar
Guessed Guessed is offline Shorten/refine recorded vba code Windows 10 Shorten/refine recorded vba code Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,185
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shorten/refine recorded vba code How to shorten English words of specific length by macro? Emby Word VBA 4 10-16-2022 11:25 PM
Shorten multi-year timeline Tyler V Visio 0 06-14-2022 08:35 AM
From recorded tro rational Ulodesk Word VBA 4 02-07-2022 06:16 AM
How to shorten Outlook server connection timeouts? mmo Outlook 0 12-12-2015 03:33 PM
Shorten/refine recorded vba code Shorten/delete auto-converted dotted horizontal line? pstein Word 3 09-12-2012 01:05 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:35 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft