Print range from command button

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
I had two separate workheets with a template on each.
I would then go to the relevant worksheet & print the page.
Not sure of the correct name but i had to select the area i would like to print,this was saved for the future prints and i see a dotted line showing this.

Ive now put both templates on one worksheet.
I am now not able to select & keep 2 print areas.

I would like to use two command buttons for the printing of the template.
How would the code be writing if say the print are is A1:K23

I will then copy the code for the other template but will alter the range for Q1:AA23
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You don't need 2 command buttons, you can just do
VBA Code:
ActiveSheet.PageSetup.PrintArea = ""
ActiveSheet.PageSetup.PrintArea = "$A$1:$K$23,$Q$1:$AA$23"
 
Upvote 0
Hi,
I will only be printing only 1 of them.
Depending on the sale it could be Template 1 or Template 2

Both will never be printed at the same time.

It would be nice to do this.
I would make a userform which would have 2 buttons.
Using you code i would select which i needed & then print
 
Upvote 0
Then you need 2 subs. One with
VBA Code:
ActiveSheet.PageSetup.PrintArea = ""
ActiveSheet.PageSetup.PrintArea = "$A$1:$K$23"
and one with
VBA Code:
ActiveSheet.PageSetup.PrintArea = ""
ActiveSheet.PageSetup.PrintArea = "$$Q$1:$AA$23"
 
Upvote 0
Would this be the same result but just a different code to produce the same thing ?

Rich (BB code):
Range("Q1:AA23").PrintOut
 
Upvote 0
The only difference when you set a print area is if you need a reprint then you can do it from the regular print options rather than run VBA.
 
Upvote 0

Forum statistics

Threads
1,214,559
Messages
6,120,194
Members
448,951
Latest member
jennlynn

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