lynnsong986
Board Regular
- Joined
- May 24, 2014
- Messages
- 146
I wrote the codes below to set up print area on all selected sheets, but it runs so slowly, can someone please modify it to make it faster?
Sub SetPrintAreaOnMultipleSheets() 'use this to set up print area for used range
Dim sh As Worksheet
For Each sh In ActiveWindow.SelectedSheets
Application.PrintCommunication = False
With sh
finalrow = sh.Cells(Rows.Count, 13).End(xlUp).Row
myrange = sh.Cells(finalrow, 14).Address
sh.PageSetup.PrintArea = "$A$1:" & myrange
sh.PageSetup.Orientation = xlPortrait
With sh.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 20
End With
End With
Next sh
Application.PrintCommunication = True
End Sub
Sub SetPrintAreaOnMultipleSheets() 'use this to set up print area for used range
Dim sh As Worksheet
For Each sh In ActiveWindow.SelectedSheets
Application.PrintCommunication = False
With sh
finalrow = sh.Cells(Rows.Count, 13).End(xlUp).Row
myrange = sh.Cells(finalrow, 14).Address
sh.PageSetup.PrintArea = "$A$1:" & myrange
sh.PageSetup.Orientation = xlPortrait
With sh.PageSetup
.FitToPagesWide = 1
.FitToPagesTall = 20
End With
End With
Next sh
Application.PrintCommunication = True
End Sub