Print each page separately

K

kaltman

Example:
I have 3 pages on one worksheet in Excel, separated by page brakes.
When someone fills in the info on page 1, OR page 2, OR page 3, how can I
get these pages to print automatically when that person clicks on the print
button?

I would only want the page that they are working in to print.

Thank you.
 
S

ShaneDevenshire

Hi,

If there is data on the 2nd and 3rd pages you do this by setting the print
area. To make it automatic you would need to write a macro and attach it to
the Before_Print even. To write such a macro for you would require more
detail, specifically what cells if filled in should trigger the printing of
Page 2 and 3.
 
K

karen

Shane,
Thank you for your response. I'm trying to build timesheets in Excell. So
Tab Oct. would have a timesheet from 9/28 - 10/4 and 10/5 - 10/11 (page 1),
10/12 - 10/18 and 10/19 - 10/24 (page 2), and finally 10/26 - 11/1 (page 3).
I figure the best control to put a macro in would be the first date of each
time frame (9/28, 10/12, 10/26, etc.). 9/28 is in cell B9. But this seems
like it will be an awful lot of work considering I need a tab for each month
(12 tabs/year, 2 or 3 pages per tab) for each employee (14). I had a program
in Access that was working, maybe I should stick with that?????
 
D

Dave Peterson

I added a bunch of horizontal page breaks (no vertical pagebreaks) to a
worksheet and used this macro to print the page that contained the activecell.

Option Explicit
Sub testme()

Dim WhichPage As Long
Dim pCtr As Long
Dim myRow As Long
Dim HPgBrk As HPageBreak
Dim wks As Worksheet

Set wks = ActiveSheet

pCtr = 0
WhichPage = 0
For Each HPgBrk In wks.HPageBreaks
pCtr = pCtr + 1
If HPgBrk.Location.Row > ActiveCell.Row Then
WhichPage = pCtr
Exit For
End If
Next HPgBrk

If WhichPage = 0 Then
MsgBox "Error trying to find what to print"
Else
wks.PrintOut from:=WhichPage, to:=WhichPage, preview:=True
End If

End Sub
 

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