View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Beto[_3_] Beto[_3_] is offline
external usenet poster
 
Posts: 140
Default 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.