Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Tere Gardner
 
Posts: n/a
Default printing - creating new files on each page break

I have a file with results from various departments/divisions in the company.
Is there any way to have each page break create a new worksheet? I have to
email each dept/div to the proper manager. There a many, many depts/div and
it takes a long time to do this each week.

thanks,
--
Tere for Stan
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Try this tester with the sheet active on a copy of your workbook
it will look at the HPageBreaks

Sub test()
Dim HPB As HPageBreak
Dim rw As Long
Dim shnum As Long
Dim Asheet As Worksheet
Dim Nsheet As Worksheet

Set Asheet = ActiveSheet
rw = 1
shnum = 1

For Each HPB In Asheet.HPageBreaks
Set Nsheet = Worksheets.Add(after:=ActiveWorkbook.Sheets(Active Workbook.Sheets.Count))
Nsheet.Name = "Page " & shnum
With Asheet
.Range(.Cells(rw, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
rw = HPB.Location.Row
shnum = shnum + 1
Next HPB
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message ...
I have a file with results from various departments/divisions in the company.
Is there any way to have each page break create a new worksheet? I have to
email each dept/div to the proper manager. There a many, many depts/div and
it takes a long time to do this each week.

thanks,
--
Tere for Stan



  #3   Report Post  
Tere Gardner
 
Posts: n/a
Default

Ron,

thanks very much. I've got one more situation that's similar. I have a
report that's very long and would like to create seperate files when the
contents of column A (Location for me) changes. It's about 8,000 rows and
creating seperate files for each week isn't possible. It would be very
helpful to have something that would do this.

regards,

"Ron de Bruin" wrote:

Try this tester with the sheet active on a copy of your workbook
it will look at the HPageBreaks

Sub test()
Dim HPB As HPageBreak
Dim rw As Long
Dim shnum As Long
Dim Asheet As Worksheet
Dim Nsheet As Worksheet

Set Asheet = ActiveSheet
rw = 1
shnum = 1

For Each HPB In Asheet.HPageBreaks
Set Nsheet = Worksheets.Add(after:=ActiveWorkbook.Sheets(Active Workbook.Sheets.Count))
Nsheet.Name = "Page " & shnum
With Asheet
.Range(.Cells(rw, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
rw = HPB.Location.Row
shnum = shnum + 1
Next HPB
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message ...
I have a file with results from various departments/divisions in the company.
Is there any way to have each page break create a new worksheet? I have to
email each dept/div to the proper manager. There a many, many depts/div and
it takes a long time to do this each week.

thanks,
--
Tere for Stan




  #4   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi Tere

You can use this example then
http://www.rondebruin.nl/copy5.htm

Look at this example
http://www.rondebruin.nl/copy5.htm#workbook



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message ...
Ron,

thanks very much. I've got one more situation that's similar. I have a
report that's very long and would like to create seperate files when the
contents of column A (Location for me) changes. It's about 8,000 rows and
creating seperate files for each week isn't possible. It would be very
helpful to have something that would do this.

regards,

"Ron de Bruin" wrote:

Try this tester with the sheet active on a copy of your workbook
it will look at the HPageBreaks

Sub test()
Dim HPB As HPageBreak
Dim rw As Long
Dim shnum As Long
Dim Asheet As Worksheet
Dim Nsheet As Worksheet

Set Asheet = ActiveSheet
rw = 1
shnum = 1

For Each HPB In Asheet.HPageBreaks
Set Nsheet = Worksheets.Add(after:=ActiveWorkbook.Sheets(Active Workbook.Sheets.Count))
Nsheet.Name = "Page " & shnum
With Asheet
.Range(.Cells(rw, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
rw = HPB.Location.Row
shnum = shnum + 1
Next HPB
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message
...
I have a file with results from various departments/divisions in the company.
Is there any way to have each page break create a new worksheet? I have to
email each dept/div to the proper manager. There a many, many depts/div and
it takes a long time to do this each week.

thanks,
--
Tere for Stan






  #5   Report Post  
Ron de Bruin
 
Posts: n/a
Default

I add a basic example on my site for the pagebreak copy
http://www.rondebruin.nl/hpagebreaks.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Ron de Bruin" wrote in message ...
Hi Tere

You can use this example then
http://www.rondebruin.nl/copy5.htm

Look at this example
http://www.rondebruin.nl/copy5.htm#workbook



--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message ...
Ron,

thanks very much. I've got one more situation that's similar. I have a
report that's very long and would like to create seperate files when the
contents of column A (Location for me) changes. It's about 8,000 rows and
creating seperate files for each week isn't possible. It would be very
helpful to have something that would do this.

regards,

"Ron de Bruin" wrote:

Try this tester with the sheet active on a copy of your workbook
it will look at the HPageBreaks

Sub test()
Dim HPB As HPageBreak
Dim rw As Long
Dim shnum As Long
Dim Asheet As Worksheet
Dim Nsheet As Worksheet

Set Asheet = ActiveSheet
rw = 1
shnum = 1

For Each HPB In Asheet.HPageBreaks
Set Nsheet = Worksheets.Add(after:=ActiveWorkbook.Sheets(Active Workbook.Sheets.Count))
Nsheet.Name = "Page " & shnum
With Asheet
.Range(.Cells(rw, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
rw = HPB.Location.Row
shnum = shnum + 1
Next HPB
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Tere Gardner" wrote in message
...
I have a file with results from various departments/divisions in the company.
Is there any way to have each page break create a new worksheet? I have to
email each dept/div to the proper manager. There a many, many depts/div and
it takes a long time to do this each week.

thanks,
--
Tere for Stan









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
changing page break in an excel file ibs81 New Users to Excel 1 April 14th 05 07:03 PM
Page Break Problem ngerm Excel Discussion (Misc queries) 1 April 6th 05 03:00 PM
adding a new page break to an existing page break Edward Letendre Excel Discussion (Misc queries) 1 March 6th 05 09:29 AM
lower horizontal page break will not move Pauline Excel Discussion (Misc queries) 4 February 27th 05 05:07 AM
content does not stay in page break notexcellent Excel Worksheet Functions 1 February 13th 05 05:55 AM


All times are GMT +1. The time now is 02:19 AM.

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"