VBA to Print Specific Sheet

VinceF

Board Regular
Joined
Sep 22, 2007
Messages
172
Office Version
  1. 2016
Platform
  1. Windows
Greetings,

I've searched the forum but was unable to find something applicable to what I need.
I set up a button and would like to assign VBA to it for printing.

I have a workbook with 9 sheets. On the sheet named "Team Generator" when I select print preview it would print 3 pages. I'd like for it to only print page 3.

Your assistance is very much appreciated.

VinceF
Win 10
Excel 2016
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
How about:

VBA Code:
Sub Macro1()
  Sheets("Team Generator").PrintOut from:=3, to:=3, preview:=True
End Sub
 
Upvote 0
How about:

VBA Code:
Sub Macro1()
  Sheets("Team Generator").PrintOut from:=3, to:=3, preview:=True
End Sub
Thank you for your reply.
When I run the code I get a Compile error invalid outside procedure error message
???
 
Upvote 0
Thank you for your reply.
When I run the code I get a Compile error invalid outside procedure error message
???
It looks like the "From" and "To" need to be capitalized, i.e.
VBA Code:
Sub Macro1()
  Sheets("Team Generator").PrintOut From:=3, To:=3, Preview:=True
End Sub
 
Upvote 0
It looks like the "From" and "To" need to be capitalized, i.e.
VBA Code:
Sub Macro1()
  Sheets("Team Generator").PrintOut From:=3, To:=3, Preview:=True
End Sub
Excellent...It's working great now
THANK YOU
 
Upvote 0
You are welcome.
Glad we were able to help.
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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
Back
Top