malik641
09-26-2005, 10:18 AM
I have some code that prints 3 seperate sections of a worksheet (all sections are from the same worksheet). I know that this code can be reduced, and I was wondering if anybody can help me do so.
Here's the code:
Sub Print_CP055()
Application.ScreenUpdating = False
'First Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_1"
'Set Page Setup
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintQuality = 600
End With
'Print
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Second Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_2"
'Print
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Third Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_3"
'Print
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Clear Print Area
ActiveSheet.PageSetup.PrintArea = ""
Application.ScreenUpdating = True
End Sub
The "Freezer_CP055_1,2,3" are all named ranges in my workbook.
How can I set all 3 ranges to three seperate print areas and have it become 3 seperate pages where I can simply print from pages 1 to 3?
Thanks in advance :hi:
Here's the code:
Sub Print_CP055()
Application.ScreenUpdating = False
'First Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_1"
'Set Page Setup
With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintQuality = 600
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Second Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_2"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Third Page
'Set Print Area
ActiveSheet.PageSetup.PrintArea = "Freezer_CP055_3"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=False, Collate:=True
'Clear Print Area
ActiveSheet.PageSetup.PrintArea = ""
Application.ScreenUpdating = True
End Sub
The "Freezer_CP055_1,2,3" are all named ranges in my workbook.
How can I set all 3 ranges to three seperate print areas and have it become 3 seperate pages where I can simply print from pages 1 to 3?
Thanks in advance :hi: