Set Print Area

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
Just a quick question I think

I currently use

Code:
 Application.Dialogs(xlDialogPrint).Show

to bring up the print dialog box.

However what I would like to do, is automatically set the print area to for example Page 1 & 4

How do I reference the page numbers, so that's all that would be printed?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
use this

ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1
ActiveWindow.SelectedSheets.PrintOut From:=4, To:=4
 
Upvote 0
Thanks,

I just figured I could use

Code:
'ActiveSheet.PageSetup.PrintArea = "A1:U54"
'Application.Dialogs(xlDialogPrint).Show

as the pages are next to each other, and I don't want it to automatically print.

However for future reference that will come in very handy, so thank you
 
Upvote 0
Quick question though,

I tried your method, which worked fine. However I now have a dashed line like - - - - all the way around the 2 pages. How do I get rid of this?
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,548
Members
452,927
Latest member
rows and columns

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