Printing more then one sheet in a workbook

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
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.
 

Some videos you may like

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
L

Legacy 98055

Guest
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
 

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
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?

Thanks once again in advance for all your help.
 
L

Legacy 98055

Guest
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
 

Yogi Anand

MrExcel MVP
Joined
Mar 12, 2002
Messages
11,454
Hi TsTom:

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

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

Regards!

Yogi
 
L

Legacy 98055

Guest
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,207
Messages
5,594,839
Members
413,943
Latest member
Dhornsby21

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top