Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishwarajanand/774e4f70bce635e6fa9191783d7092ee to your computer and use it in GitHub Desktop.
Save vishwarajanand/774e4f70bce635e6fa9191783d7092ee to your computer and use it in GitHub Desktop.
' Helps set print area of a worksheet so that print preview doesn't overflow
Public Sub PrintExcelSelection()
Dim ws As Worksheet: Set ws = ThisWorkbook.ActiveSheet
With ws.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
.PrintArea = ActiveCell.CurrentRegion.Address
End With
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment