I have the following code setup to easily print out a report that a system at my work generates..
It takes about 5 seconds to run, which I know is not soooo long.. but it seems like it should be nearly instaneous given the simplicity of the task.
Any suggestions on why its taking so long would be appreciated. Thanks.
Sub srPrintFormat()
Dim LastRow As Integer, LastColumn As Integer
Application.ScreenUpdating = False
LastRow = Range("C" & Rows.Count).End(xlUp).row
LastColumn = Cells(11, Columns.Count).End(xlToLeft).Column - 1
With ActiveSheet.PageSetup
.PrintArea = Range("C4", Cells(LastRow, LastColumn)).Address
.PrintTitleRows = "$4:$7"
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.1)
.BottomMargin = Application.InchesToPoints(0.1)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.CenterHorizontally = True
.Orientation = xlPortrait
End With
Application.ScreenUpdating = True
End Sub
It takes about 5 seconds to run, which I know is not soooo long.. but it seems like it should be nearly instaneous given the simplicity of the task.
Any suggestions on why its taking so long would be appreciated. Thanks.
Sub srPrintFormat()
Dim LastRow As Integer, LastColumn As Integer
Application.ScreenUpdating = False
LastRow = Range("C" & Rows.Count).End(xlUp).row
LastColumn = Cells(11, Columns.Count).End(xlToLeft).Column - 1
With ActiveSheet.PageSetup
.PrintArea = Range("C4", Cells(LastRow, LastColumn)).Address
.PrintTitleRows = "$4:$7"
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0.1)
.BottomMargin = Application.InchesToPoints(0.1)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.CenterHorizontally = True
.Orientation = xlPortrait
End With
Application.ScreenUpdating = True
End Sub