Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save DataSolveProblems/e1ca912f43c9d0b3cf82a3ec46ceaa66 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/e1ca912f43c9d0b3cf82a3ec46ceaa66 to your computer and use it in GitHub Desktop.
Sub PrintActiveSheet()
Dim ws As Worksheet: Set ws = ThisWorkbook.ActiveSheet
With ws.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
.PrintArea = "B1:R41"
End With
End Sub
@vishwarajanand
Copy link

vishwarajanand commented Sep 14, 2020

This was super helpful, thanks. ❤️
I changed
.PrintArea = "B1:R41"
to always set the current selection
.PrintArea = ActiveCell.CurrentRegion.Address

Ref: https://docs.microsoft.com/en-us/office/vba/api/excel.pagesetup.printarea#example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment