Make every Tab print to Landscape View

laurenh345

New Member
Joined
Mar 13, 2020
Messages
19
Office Version
  1. 2007
Platform
  1. Windows
Hi everyone,

I need help with a vba please. I have a workbook with 200 tabs and I need each one to print landscape view and have my columns print to a one page length. I have the following VBA but need some help making it a loop. Thanks in advance!

Sub FITPAGESTO_ONEPAGE()
With ActiveSheet.PageSetup
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
Sheets(sh).PageSetup.Orientation = xlLandscape
End With
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this in a copy of your workbook as macro can be undone.

VBA Code:
Sub FITPAGESTO_ONEPAGE()

Dim sh As Worksheet
    For Each sh In Sheets
    
    sh.Select
        With ActiveSheet.PageSetup
            .Zoom = False
            .FitToPagesWide = 1
            .FitToPagesTall = False
            Sheets(sh).PageSetup.Orientation = xlLandscape
        End With
    Next

End Sub
 
Upvote 0
@snjpverma, do you not get an error on the line below?
VBA Code:
Sheets(sh).PageSetup.Orientation = xlLandscape
Also see post number 2 ref: Duplicate post.
 
Upvote 0
Thank you so much for responding.Yes, I do get the run time error "data type mismatch" when I run that.
 
Upvote 0
The response from Mark858 worked and fixed the problem on my sheet. Thank you for helping me.
 
Upvote 0
Your welcome, but please in future don't duplicate questions as per the forum rules.
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,970
Members
448,933
Latest member
Bluedbw

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