Macro slows down opening time of workbook.

Grompey

New Member
Joined
Jul 19, 2023
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hello Excel gurus,

I have a question about a Macro I would like to use, however the macro increases the opening time of the workbook a lot which is kind of annoying.
The macro is as follows:

VBA Code:
Private Sub Workbook_Open()
    Dim sh As Worksheet
    For i = 1 To ActiveWorkbook.Sheets.Count
        Set sh = ActiveWorkbook.Sheets(i)
        With sh.PageSetup
        .LeftFooterPicture.FileName = "C:\\MyFile"
        .CenterFooter = "&""Tahoma""&10ActiveWorkbook.FullName"
        .RightFooter = "&""Tahoma""&10Page &P of &N "
        .LeftMargin = Application.CentimetersToPoints(1.5)
        .RightMargin = Application.CentimetersToPoints(0.5)
        .TopMargin = Application.CentimetersToPoints(1.2)
        .BottomMargin = Application.CentimetersToPoints(1.6)
        .HeaderMargin = Application.CentimetersToPoints(0.4)
        .FooterMargin = Application.CentimetersToPoints(0.8)
        End With
    Next i
End Sub

Is there a solution to make the macro run quicker? Especially with some of the bigger workbooks it will take almost 5 min to complete its cycle.
Thank you very much in advance.

Kind Regards,

Grompey
 
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Try turning off Application.PrintCommunication before starting the loop and turning it back on afterwards.
 
Upvote 0
Also, when posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
 
Upvote 0
Also, when posting vba code in the forum, please use the available code tags. It makes your code much easier to read/debug & copy. My signature block below has more details. I have added the tags for you this time. 😊
Thanks, I forgot it for this post.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top