Excel VBA Setting Page Breaks, then setting Page Print Area based on those Page Breaks

cfrehner

New Member
Joined
May 13, 2015
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have the following code running to set up the Print Area for a worksheet. Then it enters Page Breaks into the worksheet.

Code:
    With Sheets("SummaryView")
        .PageSetup.PrintArea = "$C$6:" & where.Offset(35, 0).Address
        .PageSetup.FitToPagesWide = False
        .PageSetup.FitToPagesTall = 1

    End With


     For i = xCol + 1 To where.Column Step xCol
        Sheets("SummaryView").VPageBreaks.Add Before:=Sheets("SummaryView").Cells(1, i)
    Next

My problem is this:
When it sets the page break, the page width is too wide to fit onto one page. I've tried PageSetup.Zoom = 75 to scale down the data, but this then removes the PageSetup.FitToPagesTall = 1 setting - therefore making the page too tall to fit on one page. (I understand that the .Zoom and the .FitTo settings are mutually exclusive.) I can't set the FitToPagesWide as a set number, as my data's width will vary.

What I would ideally like is to set the Vertical Page Break, keeping the FitToPagesTall = 1, and then to set the Print Area for the page I just created to fit completely on one page. Then repeat this process until the end of my data.

I hope this problem is clear, and I greatly appreciate your assistance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hoping someone will see this. In a nutshell, want to create a Print Area, set Page Breaks, then with those pages I make, set each page to print 1 page tall x 1 page wide. Any help you could offer would certainly help.

Thank you!
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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