-
Print Visible data rows
The following code is designed to print only the visible rows. But the code sets print area to individual visible rows.
[vba]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
Application.Dialogs(xlDialogPrint).Show
Range("P4").Value = Range("P4").Value + 1
Application.ScreenUpdating = True
End Sub[/vba]
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.
Best Regards,
adamsm
-
I don't think you need to do that.
[VBA].PrintArea = Range("D3:P" & LR).Address[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
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.
Best Regards,
adamsm
-
If cells are not visible, they won't print.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
But removing that line does not set my print area? How can I overcome that?
Best Regards,
adamsm
-
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Thanks for letting me know that. Now I've figured that out.
Best Regards,
adamsm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules