Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Manual page break on certain word

Hello,
I need to page break on each row containing a specific word in Col. A. I've
tried different code to accomplish this but it didn't work. I'm getting an
"object required" error which doesn't surprise me as I'm not very good at
this. Any and all help would be greatly appreciated; please be specific as
I'm rather a dolt. Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Manual page break on certain word

Maybe something like:

Option Explicit
Sub testme()
Dim myRng As Range
Dim FoundCell As Range
Dim FirstAddress As String

With Worksheets("sheet1")
.ResetAllPageBreaks 'remove them all to start
With .Range("a:a") 'what was selected??
Set FoundCell = .Find(What:="whatgoeshere", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
Lookat:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'not found on the sheet
Else
FirstAddress = FoundCell.Address
Do
If FoundCell.Row 1 Then
.Parent.HPageBreaks.Add Befo=FoundCell
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
End Sub




cottage6 wrote:

Hello,
I need to page break on each row containing a specific word in Col. A. I've
tried different code to accomplish this but it didn't work. I'm getting an
"object required" error which doesn't surprise me as I'm not very good at
this. Any and all help would be greatly appreciated; please be specific as
I'm rather a dolt. Thanks!


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Manual page break on certain word

Dave,
The code works great! I can't thank you enough and I'm sure I'll be using
it in more than one spreadsheet, so you've really helped me out.

"Dave Peterson" wrote:

Maybe something like:

Option Explicit
Sub testme()
Dim myRng As Range
Dim FoundCell As Range
Dim FirstAddress As String

With Worksheets("sheet1")
.ResetAllPageBreaks 'remove them all to start
With .Range("a:a") 'what was selected??
Set FoundCell = .Find(What:="whatgoeshere", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
Lookat:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'not found on the sheet
Else
FirstAddress = FoundCell.Address
Do
If FoundCell.Row 1 Then
.Parent.HPageBreaks.Add Befo=FoundCell
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
End Sub




cottage6 wrote:

Hello,
I need to page break on each row containing a specific word in Col. A. I've
tried different code to accomplish this but it didn't work. I'm getting an
"object required" error which doesn't surprise me as I'm not very good at
this. Any and all help would be greatly appreciated; please be specific as
I'm rather a dolt. Thanks!


--

Dave Peterson


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Manual page break on certain word

Dave, thanks a million for this! I also had the same problem.

"Dave Peterson" wrote:

Maybe something like:

Option Explicit
Sub testme()
Dim myRng As Range
Dim FoundCell As Range
Dim FirstAddress As String

With Worksheets("sheet1")
.ResetAllPageBreaks 'remove them all to start
With .Range("a:a") 'what was selected??
Set FoundCell = .Find(What:="whatgoeshere", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
Lookat:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'not found on the sheet
Else
FirstAddress = FoundCell.Address
Do
If FoundCell.Row 1 Then
.Parent.HPageBreaks.Add Befo=FoundCell
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
End Sub




cottage6 wrote:

Hello,
I need to page break on each row containing a specific word in Col. A. I've
tried different code to accomplish this but it didn't work. I'm getting an
"object required" error which doesn't surprise me as I'm not very good at
this. Any and all help would be greatly appreciated; please be specific as
I'm rather a dolt. Thanks!


--

Dave Peterson


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Manual page break on certain word

Glad it worked.

William Elerding wrote:

Dave, thanks a million for this! I also had the same problem.

"Dave Peterson" wrote:

Maybe something like:

Option Explicit
Sub testme()
Dim myRng As Range
Dim FoundCell As Range
Dim FirstAddress As String

With Worksheets("sheet1")
.ResetAllPageBreaks 'remove them all to start
With .Range("a:a") 'what was selected??
Set FoundCell = .Find(What:="whatgoeshere", _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
Lookat:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

If FoundCell Is Nothing Then
'not found on the sheet
Else
FirstAddress = FoundCell.Address
Do
If FoundCell.Row 1 Then
.Parent.HPageBreaks.Add Befo=FoundCell
End If
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
End Sub




cottage6 wrote:

Hello,
I need to page break on each row containing a specific word in Col. A. I've
tried different code to accomplish this but it didn't work. I'm getting an
"object required" error which doesn't surprise me as I'm not very good at
this. Any and all help would be greatly appreciated; please be specific as
I'm rather a dolt. Thanks!


--

Dave Peterson



--

Dave Peterson
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
Excel 2007 Page Break Adjustments causes a page break each cell BKaufman Excel Worksheet Functions 2 September 10th 10 05:02 AM
Help! How do I insert a manual page break on a change in cell contents Al Dykes Excel Discussion (Misc queries) 2 July 23rd 08 09:25 PM
How do I lighten the word "Page" (and number) in Page Break View? ExcelJockey Excel Discussion (Misc queries) 0 June 29th 06 07:26 PM
How do I show the manual page break? angels Excel Discussion (Misc queries) 1 February 9th 06 03:51 PM
Insert Page break in Word taras Excel Programming 0 November 24th 03 04:34 PM


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