ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   only manual HpageBreaks into new worksheet (https://www.excelbanter.com/excel-programming/382811-only-manual-hpagebreaks-into-new-worksheet.html)

okrob

only manual HpageBreaks into new worksheet
 
For this routine, I'd like to only make a new page for the Manual
HpageBreaks... Ron - Can you help?
Rob

http://www.rondebruin.nl/hpagebreaks.htm


Tom Ogilvy

only manual HpageBreaks into new worksheet
 
Dim i as Long
i = 0
For Each HPB In Asheet.HPageBreaks
i = i + 1
if HPB.Type = xlPageBreakManual or i = ASheet.HPageBreaks.count then
Set Nsheet = Worksheets.Add(after:=WB.Sheets(WB.Sheets.Count))
On Error Resume Next
Nsheet.Name = "Page " & PageNum
If Err.Number 0 Then
MsgBox "Change the name of : " & Nsheet.Name & " manually"
Err.Clear
End If
On Error GoTo 0
With Asheet
.Range(.Cells(RW, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
' If you want to make values of your formulas use this line also
' Nsheet.UsedRange.Value = Nsheet.UsedRange.Value
RW = HPB.Location.Row
PageNum = PageNum + 1
End if
Next HPB

--
Regards,
Tom Ogilvy


"okrob" wrote:

For this routine, I'd like to only make a new page for the Manual
HpageBreaks... Ron - Can you help?
Rob

http://www.rondebruin.nl/hpagebreaks.htm



okrob

only manual HpageBreaks into new worksheet
 
On Feb 8, 7:26 am, Tom Ogilvy
wrote:
Dim i as Long
i = 0
For Each HPB In Asheet.HPageBreaks
i = i + 1
if HPB.Type = xlPageBreakManual or i = ASheet.HPageBreaks.count then
Set Nsheet = Worksheets.Add(after:=WB.Sheets(WB.Sheets.Count))
On Error Resume Next
Nsheet.Name = "Page " & PageNum
If Err.Number 0 Then
MsgBox "Change the name of : " & Nsheet.Name & " manually"
Err.Clear
End If
On Error GoTo 0
With Asheet
.Range(.Cells(RW, "A"), .Cells(HPB.Location.Row - 1, "K")).Copy _
Nsheet.Cells(1)
End With
' If you want to make values of your formulas use this line also
' Nsheet.UsedRange.Value = Nsheet.UsedRange.Value
RW = HPB.Location.Row
PageNum = PageNum + 1
End if
Next HPB

--
Regards,
Tom Ogilvy



"okrob" wrote:
For this routine, I'd like to only make a new page for the Manual
HpageBreaks... Ron - Can you help?
Rob


http://www.rondebruin.nl/hpagebreaks.htm- Hide quoted text -


- Show quoted text -


Once again, thank you sir...



All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com