robertwp7472
New member
To anyone who needs it:
Hope this helps someone.
Code:
Sub SetPrintArea() 'Posted by Richard Winfield on January 14, 2002 on Mr. Excel 'Merged with Posting by VoG (Mr. Excel MVP) Feb 21st, 2009 'and from RichNH on www.experts-exchange.com Dim myrange As String
'Change the 7 to whatever Column Count you require A - Z = 1 - 26
myrange = Cells(Rows.Count, 7).End(xlUp).Address
With ActiveSheet.PageSetup
'Set Print area
.PrintArea = "$D$2:" & myrange 'Change $D$2 to whatever the top/left corner of desired area is
'Set Margins
.LeftMargin = 0
.RightMargin = 0
.TopMargin = 0
.BottomMargin = 0
'Set Orientation on paper
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Zoom = False
.FitToPagesWide = 1
.FitToPagesWide = False
End With
End Sub
Hope this helps someone.
Last edited: