PDA

View Full Version : Solved: Print pages that contain data



Barryj
08-06-2012, 04:45 AM
I want to print pages that contain data only, rows 1 & 2 have headers and there is also a custom header, the page setup also has rows 1 & 2 repeating for each page.

How can I modify the following macro to only print the pages that contain data from row 3.

The following macro that I have wants to print about 50 pages because the page setup has rows 1 & 2 repeating.


Private Sub CommandButton3_Click()
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
.PageSetup.PrintArea = "A3:I" & LastRow
End With
End Sub


Thanks for any help

IanFScott
08-06-2012, 06:11 AM
Not quite sure what you are after.
Are there gaps in the data resulting in blank pages?
(e.g. There is data down to row 2500 but there are gaps above such that some of the printed pages are blank).

Barryj
08-06-2012, 11:23 PM
I have included a copy of the file, when in print preview it only shows the pages that have data in them, but when you go to print it keeps printing, is this because rows 1 & 2 repeat for each page and the custom header?

jolivanes
08-07-2012, 06:47 AM
Have you tried setting your print range starting at A1 instead of A3?

Barryj
08-07-2012, 09:57 PM
Thanks jolivanes that seems to have worked, I had tried that earlier with a slightly different version of the macro.

Thanks again I will mark it as solved.