DarkJester89
Board Regular
- Joined
- Nov 5, 2017
- Messages
- 109
- Office Version
- 2016
- Platform
- Windows
Worksheet has 100 rows and about 150 columns. At any given time, only 20/40 of these will be visible.
CTRL+ UP for rows = 100 (row) Ctrl+LEFT = CS (column)
Is there a way to VBA set print area for visible rows/columns?
This is an adjacent set print area that works. New Range would be A1: to last row and column that has visible data.
I've attempted dynamic name range for print area (couldn't get that to work) and I found this code but I wouldn't work in the = range in the code above.
Thank you in advance.
CTRL+ UP for rows = 100 (row) Ctrl+LEFT = CS (column)
Is there a way to VBA set print area for visible rows/columns?
VBA Code:
Private Sub CommandButton2_Click()
Worksheets("Sheet1").PageSetup.PrintArea = Range("B:H").Address
End Sub
This is an adjacent set print area that works. New Range would be A1: to last row and column that has visible data.
I've attempted dynamic name range for print area (couldn't get that to work) and I found this code but I wouldn't work in the = range in the code above.
VBA Code:
ActiveSheet.PageSetup.PrintArea = Range("C3:I" & lastrow).Rows.SpecialCells(xlCellTypeVisible).Address
Thank you in advance.