Skip to content

Instantly share code, notes, and snippets.

View vishwarajanand's full-sized avatar

Vishwaraj Anand vishwarajanand

View GitHub Profile
View PrintExcelSelection.bas
' 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