![]() |
inserting page breaks for specific data groups
I have a list of data with three columns--I want to automatically insert page
breaks at the end of each group in a cloumn (for example: at change in curriculum code insert page break). Is this possible? If so , how? Ursula |
inserting page breaks for specific data groups
Ursula
Insert a pagebreak at each change in column A Sub InsertBreak_At_Change() Dim i As Long For i = Selection.Rows.Count To 1 Step -1 If Selection(i).Row = 1 Then Exit Sub If Selection(i) < Selection(i - 1) And Not IsEmpty _ (Selection(i - 1)) Then With Selection(i) .PageBreak = xlPageBreakManual End With End If Next End Sub Gord Dibben MS Excel MVP On Fri, 29 Sep 2006 12:44:03 -0700, Ursula Forte <Ursula wrote: I have a list of data with three columns--I want to automatically insert page breaks at the end of each group in a cloumn (for example: at change in curriculum code insert page break). Is this possible? If so , how? Ursula |
inserting page breaks for specific data groups
Let me preface with "I'm new at using Macros". What if I want to insert a
pagebreak at each change in column B? "Gord Dibben" wrote: Ursula Insert a pagebreak at each change in column A Sub InsertBreak_At_Change() Dim i As Long For i = Selection.Rows.Count To 1 Step -1 If Selection(i).Row = 1 Then Exit Sub If Selection(i) < Selection(i - 1) And Not IsEmpty _ (Selection(i - 1)) Then With Selection(i) .PageBreak = xlPageBreakManual End With End If Next End Sub Gord Dibben MS Excel MVP On Fri, 29 Sep 2006 12:44:03 -0700, Ursula Forte <Ursula wrote: I have a list of data with three columns--I want to automatically insert page breaks at the end of each group in a cloumn (for example: at change in curriculum code insert page break). Is this possible? If so , how? Ursula |
inserting page breaks for specific data groups
Gord's routine works off what you have selected.
But it also inserts a page break in column B. I'm guessing that you want the page break for the whole row: Option Explicit Sub InsertBreak_At_Change() Dim i As Long For i = Selection.Rows.Count To 1 Step -1 If Selection(i).Row = 1 Then Exit Sub If Selection(i) < Selection(i - 1) And Not IsEmpty _ (Selection(i - 1)) Then With Selection(i).EntireRow.Cells(1) .PageBreak = xlPageBreakManual End With End If Next End Sub cbuck wrote: Let me preface with "I'm new at using Macros". What if I want to insert a pagebreak at each change in column B? "Gord Dibben" wrote: Ursula Insert a pagebreak at each change in column A Sub InsertBreak_At_Change() Dim i As Long For i = Selection.Rows.Count To 1 Step -1 If Selection(i).Row = 1 Then Exit Sub If Selection(i) < Selection(i - 1) And Not IsEmpty _ (Selection(i - 1)) Then With Selection(i) .PageBreak = xlPageBreakManual End With End If Next End Sub Gord Dibben MS Excel MVP On Fri, 29 Sep 2006 12:44:03 -0700, Ursula Forte <Ursula wrote: I have a list of data with three columns--I want to automatically insert page breaks at the end of each group in a cloumn (for example: at change in curriculum code insert page break). Is this possible? If so , how? Ursula -- Dave Peterson |
inserting page breaks for specific data groups
Sub Insert_Pbreak()
Dim OldVal As String Dim rng As Range OldVal = Range("B1") Range("B1").Select Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp)).Select For Each rng In Selection If rng.Text < OldVal Then rng.PageBreak = xlPageBreakManual OldVal = rng.Text End If Next rng End Sub Gord On Thu, 26 Oct 2006 13:54:02 -0700, cbuck wrote: Let me preface with "I'm new at using Macros". What if I want to insert a pagebreak at each change in column B? "Gord Dibben" wrote: Ursula Insert a pagebreak at each change in column A Sub InsertBreak_At_Change() Dim i As Long For i = Selection.Rows.Count To 1 Step -1 If Selection(i).Row = 1 Then Exit Sub If Selection(i) < Selection(i - 1) And Not IsEmpty _ (Selection(i - 1)) Then With Selection(i) .PageBreak = xlPageBreakManual End With End If Next End Sub Gord Dibben MS Excel MVP On Fri, 29 Sep 2006 12:44:03 -0700, Ursula Forte <Ursula wrote: I have a list of data with three columns--I want to automatically insert page breaks at the end of each group in a cloumn (for example: at change in curriculum code insert page break). Is this possible? If so , how? Ursula |
All times are GMT +1. The time now is 07:11 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com