Automatic Pagebreaks

Roderick_E

Well-known Member
Joined
Oct 13, 2007
Messages
2,051
On Excel 2007-2013, if I simply format a new sheet as landscape, narrow margins; there are automatic pagebreaks. They appear to be every 34 rows or positionally the first break appears at 513.75. You'd think you could just increase in increments of 513.75 to the next break but I'm doing something wrong. I'm trying to insert charts/objects with the exact same height and widths at the very top of each page break, but somehow they keep drifting down into the next pagebreak after the 4th or 5th chart.

SAMPLE CODE:
Code:
shtop = 0 'start at very top of page
For Each Shape In activesheet.Shapes
Shape.Height = 495
Shape.Width = 665
Shape.Top = shtop
shtop = shtop + 513.75
next

Any ideas how to make the drift stop? I would simply check where the next automatic pagebreak is, but it doesn't seem accessible. Thanks
 
Well, I added a bit of compensating code...that seems to bring it back in line.
Code:
'resize charts
chartcnt2 = 0
For Each Shape In activesheet.Shapes
Shape.Height = 495
Shape.Width = 665
Shape.Top = shtop
shtop = shtop + 513.75
'account for drifting top position
If chartcnt2 > 2 Then
shtop = (shtop - 5)
End If
If chartcnt2 > 8 Then
shtop = (shtop + 2)
End If
chartcnt2 = chartcnt2 + 1
Next
You can test the Tool by downloading it from rodericke.com/xlsuper Then use the "Chart Copy" feature after LAUNCH. (will make sense when you see the UI)
 
Upvote 0

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