View Full Version : Print Visible data rows

03-19-2011, 09:17 AM
The following code is designed to print only the visible rows. But the code sets print area to individual visible rows.

Sub PrintDialogByChangingNumber()
Application.ScreenUpdating = False
Dim LR As Long
LR = Range("D" & Rows.Count).End(xlUp).Row
With ActiveSheet.PageSetup
.Orientation = xlLandscape
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintArea = Range("D3:P" & LR).SpecialCells(xlCellTypeVisible).Address
End With
Range("P4").Value = Range("P4").Value + 1
Application.ScreenUpdating = True
End Sub
How could the code be changed so that it selects the visible rows as a whole?

Any help on this would be kindly appreciated.

Thanks in advance.

03-19-2011, 09:35 AM
I don't think you need to do that.
.PrintArea = Range("D3:P" & LR).Address

03-19-2011, 09:42 AM
Thanks for the reply.

The row where I want the print area to start is; from row 3 with columns D to P.

So do you mean having that situation I don't need the above line?

Any suggestion on this would be kindly appreciated.

03-19-2011, 10:00 AM
If cells are not visible, they won't print.

03-19-2011, 10:01 AM
But removing that line does not set my print area? How can I overcome that?

03-19-2011, 10:07 AM
see Post 2

03-19-2011, 10:30 AM
Thanks for letting me know that. Now I've figured that out.