ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Page Setup Macro runs slow (https://www.excelbanter.com/excel-discussion-misc-queries/226060-page-setup-macro-runs-slow.html)

William G

Page Setup Macro runs slow
 
I have the following Macro to set up a standard page setup for all my
spreadsheets. However, it seems slower than if I were to do it
manually. I have other macros that take just a second or two to
complete. Any thoughts/feedback on this issue? I am using Excel 03.


With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&D &T"
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End Sub

Thanks,
William

Sheeloo[_4_]

Page Setup Macro runs slow
 
I made a few minor changes...

Original also ran in a couple of seconds for me...

Try
Sub setMargins()
Application.ScreenUpdating = False
With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"

ActiveSheet.PageSetup.PrintArea = ""
.LeftFooter = "&Z&F"
.RightFooter = "&D &T"
i = Application.InchesToPoints(0.5)
.LeftMargin = i
.RightMargin = i
.TopMargin = i
.BottomMargin = i
j = i = Application.InchesToPoints(0.5)
.HeaderMargin = j
.FooterMargin = j
.FitToPagesWide = 1
.FitToPagesTall = False
End With
Application.ScreenUpdating = True
End Sub


"William G" wrote:

I have the following Macro to set up a standard page setup for all my
spreadsheets. However, it seems slower than if I were to do it
manually. I have other macros that take just a second or two to
complete. Any thoughts/feedback on this issue? I am using Excel 03.


With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$1"
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
.LeftFooter = "&Z&F"
.RightFooter = "&D &T"
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.FitToPagesWide = 1
.FitToPagesTall = False
End With
End Sub

Thanks,
William


William G

Page Setup Macro runs slow
 


I updated it with your changes, still seems to be slow. I guess I'm a
bit confused as to why something with only 20 lines takes longer than
some other macros with 100s? Is it due to the Page Set up screen that
causes the 'slowness'?

Thanks,
wg

Sheeloo[_4_]

Page Setup Macro runs slow
 
I am guessing that there are lot of internal objects change when you change
the margins...

"William G" wrote:



I updated it with your changes, still seems to be slow. I guess I'm a
bit confused as to why something with only 20 lines takes longer than
some other macros with 100s? Is it due to the Page Set up screen that
causes the 'slowness'?

Thanks,
wg



All times are GMT +1. The time now is 02:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com