ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Set print range for individual sheets (ranged) in workbook. (https://www.excelbanter.com/excel-programming/372127-set-print-range-individual-sheets-ranged-workbook.html)

J.W. Aldridge

Set print range for individual sheets (ranged) in workbook.
 
I tried running several codes to group sheets and then self set the
print area but couldn't get around the first sheet having the dominant
/ default print area for all of the following sheets.

So, I have the following code (below).

I need it precede it with a code that says:
Locate worksheet named "sheet x" in this workbook.
Run this code for each individual sheet after "sheet x".



Sub Auto_prnt_setup()

Dim lLastRow As Long
lLastRow = Range("e65536:g65536").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = Range("a1:j" & lLastRow).Address
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = ""

End Sub


Any ideas?


Dave Peterson

Set print range for individual sheets (ranged) in workbook.
 
How about just doing one worksheet at a time:

Sub Auto_prnt_setup()
dim wks as worksheet
Dim lLastRow As Long
for each wks in activeworkbook.worksheets
'or
'for each wks in activewindow.selectedsheets
with wks
'I usually use just a single column
lLastRow = .Range("e65536:g65536").End(xlUp).Row
.PageSetup.PrintArea = .Range("a1:j" & lLastRow).Address
end with
next wks
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

End Sub

"J.W. Aldridge" wrote:

I tried running several codes to group sheets and then self set the
print area but couldn't get around the first sheet having the dominant
/ default print area for all of the following sheets.

So, I have the following code (below).

I need it precede it with a code that says:
Locate worksheet named "sheet x" in this workbook.
Run this code for each individual sheet after "sheet x".

Sub Auto_prnt_setup()

Dim lLastRow As Long
lLastRow = Range("e65536:g65536").End(xlUp).Row
ActiveSheet.PageSetup.PrintArea = Range("a1:j" & lLastRow).Address
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveSheet.PageSetup.PrintArea = ""

End Sub

Any ideas?


--

Dave Peterson

J.W. Aldridge

Set print range for individual sheets (ranged) in workbook.
 

.....worked GREAT !!!!

THANx



All times are GMT +1. The time now is 02:54 PM.

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