Link to home
Start Free TrialLog in
Avatar of montrof
montrofFlag for United States of America

asked on

Print Range Macro

Hi,
I would like to use a macro to cycle through multiple tabs in a workbook and setup the print range.  I want  each tab to be a page and all contents to fit on one page in landscape on a standard 8.5 by 11 page.  

Thanks
Montrof
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Try this code:

Sub MyMacro
    Dim ws As Worksheet
    
    For Each ws In ActiveWorkbook.Worksheets
        With ws.PageSetup
            .Orientation = xlLandscape
            .FitToPagesWide = 1
            .FitToPagesTall = 1
        End With
        
        On Error Resume Next
    Next ws
    
End Sub

Open in new window

Try this on your selected sheets

Sub Macro1()
'
' Macro1 Macro
'
Dim sht As Worksheet

Application.PrintCommunication = False

For Each sht In ActiveWindow.SelectedSheets
    
    With sht.PageSetup
        .Orientation = xlLandscape
        .PaperSize = xlPaperLetter
        .FitToPagesWide = 1
        .FitToPagesTall = 1
    End With
    
Next sht

Application.PrintCommunication = True
End Sub

Open in new window


Thomas
Avatar of montrof

ASKER

Thank you for the Macros but neither work, Each tab is still showing mutiple pages. I do not know if it maters but there are graphs on the tabs.
ASKER CERTIFIED SOLUTION
Avatar of Michael Vasilevsky
Michael Vasilevsky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of montrof

ASKER

Perfect thank you so much for the help