ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel: how to insert page breaks between all the rows at once? (https://www.excelbanter.com/excel-discussion-misc-queries/192571-excel-how-insert-page-breaks-between-all-rows-once.html)

Kim

Excel: how to insert page breaks between all the rows at once?
 
Excel: how to insert page breaks between all the rows at once?

Thomas [PBD]

Excel: how to insert page breaks between all the rows at once?
 
Kim,

Here is a macro that will accomplish what you are asking for. What it does
is add a page break on every row for all used cells.

Go to VBA (ToolsMacroVisual Basic Editor) and create a new Module for the
coding (InsertModule) and paste this code in, close VBA.
Run the Macro from Excel (ToolsMacroMacrosAdd_PageBreaks)

Public Sub Add_PageBreaks()
Dim xlssheet As Worksheet
Set xlssheet = Excel.ActiveSheet
Dim x As Long
Dim y As Long
Dim actcell As String
y = xlssheet.UsedRange.Rows.Count


For x = 2 To y
actcell = "$A$" & x
xlssheet.Range(actcell).Select
ActiveWindow.SelectedSheets.HPageBreaks.Add befo=ActiveCell
Next

End Sub

--
--Thomas [PBD]
Working hard to make working easy.


"Kim" wrote:

Excel: how to insert page breaks between all the rows at once?



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

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