# Printing more then one sheet in a workbook

#### imported_unknown

##### Active Member
Printing question, I have a work book with multiple sheets working on Gratuity

Input sheet1
Button1 Button2 button3 ……so on
Sheet1
Sheet2
Sheet3
Sheet4…………Sheet12
The input sheet is obviously where the person inputs the information.

What my question is I need a method of printing the other sheets through a button or something else.
When button1 is pressed it prints out sheet1 and 4 but not 3
Button 2 sheet3 and 6 but not 1
That I can do by recording macro, but here is where I get totally lost.

If on the input sheet if a person has worked more then (calculated in cell A1(start date)-A2(end date)=total years) 5 years it prints out sheet 1 one and 2. But a person who has worked 10 years it sheets it prints out sheet 1,2,5 and 6 when button 1 is pushed and so on.
I am really new to excel so I am hoping I have asked this question in the right way so it is understandable. Any help would be greatly appreciated. If you are able to assist please make it as simple as possible.

### Excel Facts

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Hi
You could use code similar to this:
<pre>
Sheets("Sheet1").PrintOut
Sheets("Sheet2").PrintOut

If DateDiff("y", [A1], [A2]) > 9 Then
Sheets("Sheet5").PrintOut
Sheets("Sheet6").PrintOut
End If

</pre>
Tom

Thanks a lot that was a really response. It worked great except one thing it is calculating 9 days and not 9 years of service.
Is it that I should put should input 3285 is stead of 9. Or is there a way of writing so it understand years that is years and not days?

OOPS! "yyyy" is for "years".
"y" is for "day of the year".

Maybe change to this:<pre>
If DateDiff("yyyy", Sheet1.Range("A1").Value, _
Sheet1.Range("A2").Value) > 9 Then
Sheets("Sheet5").PrintOut
Sheets("Sheet6").PrintOut
End If</pre>

Tom
This message was edited by TsTom on 2002-10-05 22:27

Hi TsTom:

Datediff("y",... will give difference in number of days

Datediff("yyyy",... to get difference in number of years

Regards!

Yogi

Juan,
I stand corrected...
Next time I'll check the help file.

<pre>
The interval argument has these settings:

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

</pre>

Tom

Replies
3
Views
326
Replies
10
Views
481
Replies
2
Views
820
Replies
24
Views
1K
Replies
5
Views
191

1,218,746
Messages
6,144,258
Members
450,533
Latest member
xoxo1998

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back