Creating print area - multiple sheets - fit to one sheet

Dreamteam

New Member
Joined
Feb 22, 2018
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I have the following code that runs through multiple sheets creating a named range/print area - to fit to one sheet in readiness for printing. It is successfully creating the print area/named range on each sheet (that has a numerical name) but it is not setting it up for printing on one sheet. I have been on this for ages and I must be missing something relatively simple? Maybe not?

Any help much appreciated.

Many thanks

Dt

Sub CreatePrint_Area()
Application.ScreenUpdating = False

Application.Calculation = xlCalculationManual


Dim ws As Worksheet
Dim wb As Workbook

Set wb = ThisWorkbook

For Each ws In wb.Worksheets
If IsNumeric(ws.Name) Then

With ActiveSheet.PageSetup

.PrintArea = "$a$1:$z$71"
.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1

End With
End If
Next ws

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Maybe...
Code:
With ws.Name.PageSetup
HTH. Dave
ps You could probably get rid of the wb variable..
Code:
For Each ws In ThisWorkbook.Sheets
 
Upvote 0
This has worked perfectly - I have checked many of the numeric worksheets just to be sure.

Many many thanks

Dt
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top