ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   set print area on multiple sheets (https://www.excelbanter.com/excel-programming/439745-set-print-area-multiple-sheets.html)

J.W. Aldridge

set print area on multiple sheets
 

I've tried several ways to do this, but haven't been successful yet.
Need to run "printareamacro" on all sheets after Ind_brkdwn.

Sub PRINTING_PLEASE()
Dim sh As Worksheet
'for each sheet in workbook after "ind templates"
x = Sheets("IND_BRKDWN").Index
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Call printareamacro
End If
Next
'Application.CutCopyMode = False
End Sub
----------------------------------------------------------------------
Sub printareamacro()
Cells.Select
Cells.EntireColumn.AutoFit
Range("A1").Select

With ActiveSheet.PageSetup
.PrintArea = Range("a1").CurrentRegion.Address
.Orientation = xlLandscape
.CenterHorizontally = True
.CenterVertically = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

With Selection.Font
.Name = "Arial"
.Size = 12
End With
End With
'ActiveSheet.PrintPreview
Cells.EntireColumn.AutoFit
End Sub

J.W. Aldridge

set print area on multiple sheets
 
adjusted the two.

wrong number of arguments or invalid property assignment.




Sub printareamacro()
mySh As Object
With mySh
With .PageSetup
.PrintArea = .Range("a1").CurrentRegion.Address
.Orientation = xlLandscape
.CenterHorizontally = True
.CenterVertically = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

With .Cells.Font
.Name = "Arial"
.Size = 12
End With

.Cells.EntireColumn.AutoFit
'.PrintPreview
End With
End Sub



Sub pRINT_EM()
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Call printareamacro(mySh:=sh)
End If
Next sh

End Sub

Dave Peterson

set print area on multiple sheets
 
Option Explicit
Sub PRINTING_PLEASE()
Dim sh As Worksheet
Dim x As Long
'for each sheet in workbook after "ind templates"
x = Sheets("IND_BRKDWN").Index
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Call printareamacro(mySh:=sh)
End If
Next sh
'Application.CutCopyMode = False
End Sub
Sub printareamacro(mySh As Object)
With mySh
With .PageSetup
.PrintArea = .Parent.Range("a1").CurrentRegion.Address
.Orientation = xlLandscape
.CenterHorizontally = True
.CenterVertically = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

With .Cells.Font
.Name = "Arial"
.Size = 12
End With

.Cells.EntireColumn.AutoFit
'.PrintPreview
End With
End Sub


"J.W. Aldridge" wrote:

adjusted the two.

wrong number of arguments or invalid property assignment.

Sub printareamacro()
mySh As Object
With mySh
With .PageSetup
.PrintArea = .Range("a1").CurrentRegion.Address
.Orientation = xlLandscape
.CenterHorizontally = True
.CenterVertically = True
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

With .Cells.Font
.Name = "Arial"
.Size = 12
End With

.Cells.EntireColumn.AutoFit
'.PrintPreview
End With
End Sub

Sub pRINT_EM()
For Each sh In ThisWorkbook.Sheets
If sh.Index x Then
Call printareamacro(mySh:=sh)
End If
Next sh

End Sub


--

Dave Peterson

J.W. Aldridge

set print area on multiple sheets
 
Thanx for all the help!


All times are GMT +1. The time now is 07:24 AM.

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