ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   moving table to next page (https://www.excelbanter.com/excel-programming/312526-moving-table-next-page.html)

tess457[_5_]

moving table to next page
 

doesnt this always add a page break no matter what, whether or not th
table fits. I tried it anyways and got a runtime error
"application-defined or object-defined error."

Set rnData = ActiveSheet.UsedRange
Let irows = rnData.CurrentRegion.Rows.Count
Let Count = irows + 26

Range("A" & Count).Activate
ActiveWindow.SelectedSheets.HPageBreaks.Add _
Befo=ActiveCell
ActiveWindow.SelectedSheets.VPageBreaks.Add _
Befo=ActiveCell

I would like to only add a page break, if the entire table (which is 2
rows, plus 5 rows spacing) doesnt fit on the last page. In other words
if there isnt 26 lines left till the end of the page, I want to add
page break before the table....is this possible?

--
tess45
-----------------------------------------------------------------------
tess457's Profile: http://www.excelforum.com/member.php...fo&userid=1393
View this thread: http://www.excelforum.com/showthread.php?threadid=26619



All times are GMT +1. The time now is 02:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com