Control printing?

R

Robert Crandal

Our daily spreadsheet template contains 10 printable pages. Each
page contains 5 rows of header information and 25 rows for data entry.
(In other words, one page equals 30 rows). Users will typically
fill up anywhere between 0-6 pages per day.

Here's my problem:

Whenever a user presses 'Print' (or even Ctrl-P), Excel will automatically
print all 10 pages. This will often waste paper, because what if a user
only fills up 2 pages with data? That means the remaining 8 empty pages
get printed as well.

So, if a user presses 'Print' or Ctrl-P, how can I tell Excel to only print
the
pages that contain data?

Thanks!
 
C

Claus Busch

Hi Robert,

Am Fri, 25 Jan 2013 11:54:27 -0700 schrieb Robert Crandal:
Whenever a user presses 'Print' (or even Ctrl-P), Excel will automatically
print all 10 pages. This will often waste paper, because what if a user
only fills up 2 pages with data? That means the remaining 8 empty pages
get printed as well.

set print area new for each print job:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim LRow As Long
Dim LCol As Integer

With ActiveSheet
LRow = .Cells(.Rows.Count, 1).End(xlUp).Row
LCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
With .PageSetup
.PrintArea = ""
.PrintArea = "$A$1:" & Cells(LRow, LCol).Address
End With
End With
End Sub


Regards
Claus Busch
 
R

Robert Crandal

Cool, so the basic idea is to process "Workbook_BeforePrint()"
and set the page setup ".PrintArea".

Thank you Claus! 8)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top