Set printarea to print on different pages

dracken

New Member
Joined
Jun 8, 2015
Messages
4
Hello Everyone,

I'm working on a code that could set multiple printarea and use the defined print area to print on different pages.
Reading the 6 pages of topics on Printarea, I did not find anything that solve my problem.

Here is what I want to do :
I have a worksheet with lots of columns. I would like to define 3 printarea using the following ranges : (A1:P33), (Q1:AE33) and (AF1:AT33)

When I go in the print preview I'd like to have range1 on page 1, range2 on page 2 and range3 on page 3.

Is this even possible for excel to remember the printarea and set it in different pages?

I wrote the code below but it gives me only one page with the 3 ranges on it.

Code:
Sheets("TableauFormate").Select
     
    Let rngProjet1 = "$A$1" & ":" & "$P$33"
    Let rngProjet2 = "$Q$1" & ":" & "$AE$33"
    Let rngProjet3 = "$AF$1" & ":" & "$AT$33"


    With ActiveSheet
        ActiveSheet.PageSetup.PrintArea = rngProjet1 '& "," & rngProjet2 & "," & rngProjet3
    End With

With ActiveSheet.PageSetup
.CenterHorizontally = True
.CenterVertically = True
.Orientation = xlLandscape
.LeftMargin = Application.InchesToPoints(0)
.RightMargin = Application.InchesToPoints(0)
.TopMargin = Application.InchesToPoints(0)
.BottomMargin = Application.InchesToPoints(0)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PrintQuality = 600
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

Some help would be greatly appreciated :)

Thank you in advance

Dracken
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
When you have adjoining ranges like that, what you are trying to accomplish is going to be problematic. I don't know exactly why the print ops work a little differently when executed from inside VBA... which seems to like taking adjoining ranges and applying a "UNION" type action to them? ...but it does, and that is a problem for you in this case.

Alternatively, think about first copy/pasting those ranges to a separate sheet (so they are not adjoining) and then just run your print operation off the new sheet.
 
Upvote 0
Hello Aaron,

Thank you for your reply.
As you proposed, I think I'll just copy/paste my 3 ranges, each in one page.
That would be more convenient to keep them all in on page but it seems it's not possible.

Anyway thank for the help

Dracken
 
Upvote 0

Forum statistics

Threads
1,196,280
Messages
6,014,438
Members
441,819
Latest member
Blackov

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