Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 63
Default Insert pagebreak when a specific word appears in a column.

Hi,
I am importing a spreadsheet from another application which has the word
"Account" appearing multiple times in the first column.
I would like to create a Macro that will search for each occurance and
insert a page break above the row containing the word.
Not sure if this is possible?
Any help would be greatly appreciated.
Thanks, Neal...
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,805
Default Insert pagebreak when a specific word appears in a column.

Try the macro
Sub insertBreak()
Dim c As Range, s As Long
lastRow = ActiveSheet.Cells(65000, "A").End(xlUp).Row
Range("A1:A" & lastRow).Select
Set c = Selection.Find("Account")
Rows(c.Row).PageBreak = xlPageBreakManual
End Sub

It will insert a break before the first occurence of "Account" on the active
sheet

"Neal" wrote:

Hi,
I am importing a spreadsheet from another application which has the word
"Account" appearing multiple times in the first column.
I would like to create a Macro that will search for each occurance and
insert a page break above the row containing the word.
Not sure if this is possible?
Any help would be greatly appreciated.
Thanks, Neal...

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Insert pagebreak when a specific word appears in a column.

Option Compare Text
Sub Insert_PBreak_Col()
Dim rng As Range
Dim Cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(1))
For Each Cell In rng
If Cell.Text = "Account" Then
Cell.PageBreak = xlPageBreakManual
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Fri, 24 Oct 2008 12:31:03 -0700, Neal
wrote:

Hi,
I am importing a spreadsheet from another application which has the word
"Account" appearing multiple times in the first column.
I would like to create a Macro that will search for each occurance and
insert a page break above the row containing the word.
Not sure if this is possible?
Any help would be greatly appreciated.
Thanks, Neal...


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 63
Default Insert pagebreak when a specific word appears in a column.

Hi Gord,

This worked great! thanks for your help on this.

Cheers, Neal...

"Gord Dibben" wrote:

Option Compare Text
Sub Insert_PBreak_Col()
Dim rng As Range
Dim Cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(1))
For Each Cell In rng
If Cell.Text = "Account" Then
Cell.PageBreak = xlPageBreakManual
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Fri, 24 Oct 2008 12:31:03 -0700, Neal
wrote:

Hi,
I am importing a spreadsheet from another application which has the word
"Account" appearing multiple times in the first column.
I would like to create a Macro that will search for each occurance and
insert a page break above the row containing the word.
Not sure if this is possible?
Any help would be greatly appreciated.
Thanks, Neal...



  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Insert pagebreak when a specific word appears in a column.

Good to hear.

Thanks for the feedback

On Mon, 27 Oct 2008 12:44:03 -0700, Neal
wrote:

Hi Gord,

This worked great! thanks for your help on this.

Cheers, Neal...

"Gord Dibben" wrote:

Option Compare Text
Sub Insert_PBreak_Col()
Dim rng As Range
Dim Cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(1))
For Each Cell In rng
If Cell.Text = "Account" Then
Cell.PageBreak = xlPageBreakManual
End If
Next
End Sub


Gord Dibben MS Excel MVP

On Fri, 24 Oct 2008 12:31:03 -0700, Neal
wrote:

Hi,
I am importing a spreadsheet from another application which has the word
"Account" appearing multiple times in the first column.
I would like to create a Macro that will search for each occurance and
insert a page break above the row containing the word.
Not sure if this is possible?
Any help would be greatly appreciated.
Thanks, Neal...






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
Count how many times the same word appears in column Alexa Excel Discussion (Misc queries) 6 April 9th 23 12:51 PM
Count the number of times specific text appears in a column Nannie Excel Worksheet Functions 5 August 27th 08 07:09 PM
Cant move pagebreak in PageBreak View in Excel2003 Vasanthan Excel Worksheet Functions 1 August 22nd 07 03:28 PM
INSERT HORIZONTAL PAGEBREAK AFTER EACH LINE IN ENTIRE WORKSHEET . KNPALIA Excel Worksheet Functions 1 October 27th 06 05:46 PM
count the number of times a specific word appears in a column BAR Excel Worksheet Functions 1 June 27th 06 05:03 PM


All times are GMT +1. The time now is 03:35 PM.

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

About Us

"It's about Microsoft Excel"