View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Thomas [PBD] Thomas [PBD] is offline
external usenet poster
 
Posts: 154
Default 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?