ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Inserting Page Breaks every 40 lines... (https://www.excelbanter.com/excel-programming/288422-inserting-page-breaks-every-40-lines.html)

Trevor Hargrove

Inserting Page Breaks every 40 lines...
 
Hello all,

I would like to be able to insert a page break every 40 lines of a
large file. Is this possible either through add-ins or via VB code?
Any help is appreciated.

Thanks,

Trevor

Beto[_3_]

Inserting Page Breaks every 40 lines...
 
Trevor Hargrove wrote:

Hello all,

I would like to be able to insert a page break every 40 lines of a
large file. Is this possible either through add-ins or via VB code?
Any help is appreciated.


Hi, you can use this... I guess you better adapt it to your needs,
because it takes a while to add them. 1026 is the max number of
linebreaks in a spreadsheet.

For i = 1 To 1026
ActiveWindow.SelectedSheets.HPageBreaks.Add _
Befo=Cells(i * 40 + 1, 1)
Next i

At least this should get you started. It would be better if you add some
code to detect when the data has ended.
Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



All times are GMT +1. The time now is 07:44 AM.

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