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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,889
Messages
6,175,223
Members
452,620
Latest member
dsubash

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