Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Insert page break

Hi,

I have a long report with several lines on worksheet "Sheet1".
I would like to have a code that would insert a page break every time
there is the word "Break" on column C.
Note that the page break would be just above the line indicating
"Break".

Thanks in advance for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Insert page break


Sub dopagbreaks()
ActiveSheet.ResetAllPageBreaks

With Range("c1:c500")
Set c = .Find("Break", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
ActiveSheet.HPageBreaks.Add Befo=Rows(c.Row)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub



On Oct 14, 12:28*pm, Norvascom wrote:
Hi,

I have a long report with several lines on worksheet "Sheet1".
I would like to have a code that would insert a page break every time
there is the word "Break" on column C.
Note that the page break would be just above the line indicating
"Break".

Thanks in advance for your help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Insert page break

hi Norvascom,

Sub AddHPageBreaks()
For i = 1 To Range("C65536").End(xlUp).Row
If Range("C" & i) = "Break" Then ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=Range("C" & i)
Next
End Sub

Sub DeleteHPageBreaks()
For i = ActiveSheet.HPageBreaks.Count To 1 Step -1
ActiveSheet.HPageBreaks(i).Delete
Next
End Sub


--
isabelle




Le 2011-10-14 13:28, Norvascom a écrit :
Hi,

I have a long report with several lines on worksheet "Sheet1".
I would like to have a code that would insert a page break every time
there is the word "Break" on column C.
Note that the page break would be just above the line indicating
"Break".

Thanks in advance for your help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default Insert page break

for a large data range, the macro will be more faster by using "Find... Next"


--
isabelle



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Page Break da Excel Discussion (Misc queries) 2 May 11th 09 07:05 PM
INSERT ROW AND PAGE BREAK jcontrer Excel Discussion (Misc queries) 0 May 15th 08 07:09 PM
insert page break ruben via OfficeKB.com Excel Programming 3 May 11th 06 11:57 AM
cannot insert page break tsmanz Excel Discussion (Misc queries) 2 December 5th 05 05:45 PM
Insert Page Break Don Excel Discussion (Misc queries) 3 June 9th 05 08:32 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"