Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 19
Default Inserting page breaks

I have written a macro that will insert page breaks in my workbook everytime
the word "Date:" is found.

How can I eliminate Excel's automatic page breaks and use only my manual
page breaks?

Thank you in advance.

Rich Mogy
Here is the macro:
Sub pagebreaker3()

'

Dim FirstAddress As String


'

Range("A2").Select

Set c = Cells.Find(What:="Date:", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=True)
'above saves the address of the find
If Not c Is Nothing Then
FirstAddress = c.Address 'saves first address
Range(c.Address).Select 'selects row with address
Else
Exit Sub
End If
Do Until c.Address = "$A$1"
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
'inserts page break
Set c = Cells.FindNext(c) 'finds next occurrence
Range(c.Address).Select 'select row with next occurrence
Loop
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Inserting page breaks


Try this instead

Sub SetPageBreaks_Don()
With ActiveSheet.Cells
..PageBreak = xlPageBreakNone

Set c = Cells.Find(What:="date", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'MsgBox c.Row
ActiveSheet.HPageBreaks.Add Befo=.Cells(c.Row, 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have written a macro that will insert page breaks in my workbook
everytime the word "Date:" is found.

How can I eliminate Excel's automatic page breaks and use only my manual
page breaks?

Thank you in advance.

Rich Mogy
Here is the macro:
Sub pagebreaker3()

'

Dim FirstAddress As String


'

Range("A2").Select

Set c = Cells.Find(What:="Date:", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=True)
'above saves the address of the find
If Not c Is Nothing Then
FirstAddress = c.Address 'saves first address
Range(c.Address).Select 'selects row with address
Else
Exit Sub
End If
Do Until c.Address = "$A$1"
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
'inserts page break
Set c = Cells.FindNext(c) 'finds next occurrence
Range(c.Address).Select 'select row with next occurrence
Loop
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 19
Default Inserting page breaks

That only removes my created page breaks. I'm trying to only have my page
breaks occurr, not Excels default.

Rich
"Don Guillett" wrote in message
...

Try this instead

Sub SetPageBreaks_Don()
With ActiveSheet.Cells
.PageBreak = xlPageBreakNone

Set c = Cells.Find(What:="date", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'MsgBox c.Row
ActiveSheet.HPageBreaks.Add Befo=.Cells(c.Row, 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have written a macro that will insert page breaks in my workbook
everytime the word "Date:" is found.

How can I eliminate Excel's automatic page breaks and use only my manual
page breaks?

Thank you in advance.

Rich Mogy
Here is the macro:
Sub pagebreaker3()

'

Dim FirstAddress As String


'

Range("A2").Select

Set c = Cells.Find(What:="Date:", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=True)
'above saves the address of the find
If Not c Is Nothing Then
FirstAddress = c.Address 'saves first address
Range(c.Address).Select 'selects row with address
Else
Exit Sub
End If
Do Until c.Address = "$A$1"
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
'inserts page break
Set c = Cells.FindNext(c) 'finds next occurrence
Range(c.Address).Select 'select row with next occurrence
Loop
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Inserting page breaks

Fully tested using your example. If desired, send your wb to my address
below along with very specific instructions and before/after examples.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
That only removes my created page breaks. I'm trying to only have my page
breaks occurr, not Excels default.

Rich
"Don Guillett" wrote in message
...

Try this instead

Sub SetPageBreaks_Don()
With ActiveSheet.Cells
.PageBreak = xlPageBreakNone

Set c = Cells.Find(What:="date", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Do
'MsgBox c.Row
ActiveSheet.HPageBreaks.Add Befo=.Cells(c.Row, 1)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich Mogy" wrote in message
...
I have written a macro that will insert page breaks in my workbook
everytime the word "Date:" is found.

How can I eliminate Excel's automatic page breaks and use only my manual
page breaks?

Thank you in advance.

Rich Mogy
Here is the macro:
Sub pagebreaker3()

'

Dim FirstAddress As String


'

Range("A2").Select

Set c = Cells.Find(What:="Date:", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=True)
'above saves the address of the find
If Not c Is Nothing Then
FirstAddress = c.Address 'saves first address
Range(c.Address).Select 'selects row with address
Else
Exit Sub
End If
Do Until c.Address = "$A$1"
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
'inserts page break
Set c = Cells.FindNext(c) 'finds next occurrence
Range(c.Address).Select 'select row with next occurrence
Loop
End Sub




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
How do I do page breaks when view menu doesnt page break preview HeatherF55 Excel Discussion (Misc queries) 0 September 21st 07 04:24 AM
Inserting Page Breaks blasds78 Excel Discussion (Misc queries) 3 May 22nd 07 03:57 PM
inserting page breaks for specific data groups Ursula Forte Excel Discussion (Misc queries) 4 October 27th 06 01:16 AM
inserting multiple page breaks at one time JPRENDER Excel Discussion (Misc queries) 0 March 22nd 06 04:46 PM
Inserting Page Breaks chrisnelsonusa1 Excel Discussion (Misc queries) 3 December 9th 05 09:34 PM


All times are GMT +1. The time now is 02:43 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"