Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Re-setting HPageBreaks

I have a worksheet where the number of rows changes according to how many
names are added or deleted to the worksheet. I am trying to adjust the
HPageBreaks to accomodate the new range for printout. It seems to work up to
a point for a certain number of rows. My current sheet has row 86 as it's
last row and HPageBreaks(1) is at row 73. I want to move it to row 87 so all
the list will print to one page. I remmed one line that didn't work and
added a line above it, which also doesn't work. The remmed line gives a
runtime error 1004, the new line gives no error, but neither does it move
the page break. Any ideas would be appreciated.
XL 2000-2003

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).Location =
Worksheets(1).Range(rng.Address)
' Worksheets(1).HPageBreaks(1).DragOff xlDown, 1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp, RegionIndex:=1
End If
End Sub

Mike F


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Re-setting HPageBreaks

Mike,
Excel inserts automatic page breaks if the data won't print on one page
(no matter what).
I would set a print area, specify one page tall and not screw with
the page breaks.
--
Jim Cone
Portland, Oregon USA



"Mike Fogleman"

wrote in message
I have a worksheet where the number of rows changes according to how many
names are added or deleted to the worksheet. I am trying to adjust the
HPageBreaks to accomodate the new range for printout. It seems to work up to
a point for a certain number of rows. My current sheet has row 86 as it's
last row and HPageBreaks(1) is at row 73. I want to move it to row 87 so all
the list will print to one page. I remmed one line that didn't work and
added a line above it, which also doesn't work. The remmed line gives a
runtime error 1004, the new line gives no error, but neither does it move
the page break. Any ideas would be appreciated.
XL 2000-2003

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).Location =
Worksheets(1).Range(rng.Address)
' Worksheets(1).HPageBreaks(1).DragOff xlDown, 1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp, RegionIndex:=1
End If
End Sub

Mike F


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Re-setting HPageBreaks

Doing that messes up the vertical page breaks. I have them set so that 10
columns will print per page, for 18 pages, thru column FX. I can manually
drag the horizontal to where I want, but can't seem to do it with code.
Recording a macro doing it manually produces

ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1

which gave the runtime error when done after the worksheet was modified with
the new list. I really need to set the horizontal to the last row + 1 of
column B, in order for the 18 pages to print 10 columns wide each. Any other
suggestions?

Mike F
"Jim Cone" wrote in message
...
Mike,
Excel inserts automatic page breaks if the data won't print on one page
(no matter what).
I would set a print area, specify one page tall and not screw with
the page breaks.
--
Jim Cone
Portland, Oregon USA



"Mike Fogleman"

wrote in message
I have a worksheet where the number of rows changes according to how many
names are added or deleted to the worksheet. I am trying to adjust the
HPageBreaks to accomodate the new range for printout. It seems to work up
to
a point for a certain number of rows. My current sheet has row 86 as it's
last row and HPageBreaks(1) is at row 73. I want to move it to row 87 so
all
the list will print to one page. I remmed one line that didn't work and
added a line above it, which also doesn't work. The remmed line gives a
runtime error 1004, the new line gives no error, but neither does it move
the page break. Any ideas would be appreciated.
XL 2000-2003

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).Location =
Worksheets(1).Range(rng.Address)
' Worksheets(1).HPageBreaks(1).DragOff xlDown, 1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp,
RegionIndex:=1
End If
End Sub

Mike F




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Re-setting HPageBreaks

Mike,
You can remove all "manual" page breaks with...
Cells.PageBreak = xlNone
and then place new manual page breaks where you want them...
Rows(87).PageBreak = xlPageBreakManual

However, let me repeat, Excel inserts automatic page breaks
where necessary to fit the data to the page size. You cannot
remove automatic page breaks, you can only change where
they appear by your placement of the manual breaks.

You can change the PageSetup.Zoom setting or change the
row height to make something fit on a page.
So setting a page break at row 87 and setting the zoom to 90% or so
might be something that would work for you.
--
Jim Cone
Portland, Oregon USA



"Mike Fogleman"

wrote in message
Doing that messes up the vertical page breaks. I have them set so that 10
columns will print per page, for 18 pages, thru column FX. I can manually
drag the horizontal to where I want, but can't seem to do it with code.
Recording a macro doing it manually produces

ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1

which gave the runtime error when done after the worksheet was modified with
the new list. I really need to set the horizontal to the last row + 1 of
column B, in order for the 18 pages to print 10 columns wide each. Any other
suggestions?

Mike F
"Jim Cone"

wrote in message
Mike,
Excel inserts automatic page breaks if the data won't print on one page
(no matter what).
I would set a print area, specify one page tall and not screw with
the page breaks.
--
Jim Cone
Portland, Oregon USA



"Mike Fogleman"

wrote in message
I have a worksheet where the number of rows changes according to how many
names are added or deleted to the worksheet. I am trying to adjust the
HPageBreaks to accomodate the new range for printout. It seems to work up
to
a point for a certain number of rows. My current sheet has row 86 as it's
last row and HPageBreaks(1) is at row 73. I want to move it to row 87 so
all
the list will print to one page. I remmed one line that didn't work and
added a line above it, which also doesn't work. The remmed line gives a
runtime error 1004, the new line gives no error, but neither does it move
the page break. Any ideas would be appreciated.
XL 2000-2003

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).Location =
Worksheets(1).Range(rng.Address)
' Worksheets(1).HPageBreaks(1).DragOff xlDown, 1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp,
RegionIndex:=1
End If
End Sub

Mike F




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Re-setting HPageBreaks

I figured out the runtime problem with the DragOff method. The window must
be in page break view for the DragOff method to have access to the
HPageBreak. Does anyone see a different way to use the DragOff method or
refer to the object it needs without going to PageBreakPreview?

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
ActiveWindow.View = xlPageBreakPreview
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlDown,
RegionIndex:=1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp, RegionIndex:=1
End If
ActiveWindow.View = xlNormalView
End Sub
"Mike Fogleman" wrote in message
...
Doing that messes up the vertical page breaks. I have them set so that 10
columns will print per page, for 18 pages, thru column FX. I can manually
drag the horizontal to where I want, but can't seem to do it with code.
Recording a macro doing it manually produces

ActiveSheet.HPageBreaks(1).DragOff Direction:=xlDown, RegionIndex:=1

which gave the runtime error when done after the worksheet was modified
with the new list. I really need to set the horizontal to the last row + 1
of column B, in order for the 18 pages to print 10 columns wide each. Any
other suggestions?

Mike F
"Jim Cone" wrote in message
...
Mike,
Excel inserts automatic page breaks if the data won't print on one page
(no matter what).
I would set a print area, specify one page tall and not screw with
the page breaks.
--
Jim Cone
Portland, Oregon USA



"Mike Fogleman"

wrote in message
I have a worksheet where the number of rows changes according to how many
names are added or deleted to the worksheet. I am trying to adjust the
HPageBreaks to accomodate the new range for printout. It seems to work up
to
a point for a certain number of rows. My current sheet has row 86 as it's
last row and HPageBreaks(1) is at row 73. I want to move it to row 87 so
all
the list will print to one page. I remmed one line that didn't work and
added a line above it, which also doesn't work. The remmed line gives a
runtime error 1004, the new line gives no error, but neither does it move
the page break. Any ideas would be appreciated.
XL 2000-2003

Sub SetHPB()
Dim rng As Range, Hrng As Range
Dim LRow As Long
Dim c As Long
c = Worksheets(1).HPageBreaks.Count
If c = 0 Then Exit Sub
LRow = Cells(Rows.Count, "B").End(xlUp).Row + 1
Set rng = Range("A" & LRow)
Set Hrng = Worksheets(1).HPageBreaks(1).Location
If rng.Address = Hrng.Address Then Exit Sub
If Hrng.Row < rng.Row Then
Worksheets(1).HPageBreaks(1).Location =
Worksheets(1).Range(rng.Address)
' Worksheets(1).HPageBreaks(1).DragOff xlDown, 1
Else
Worksheets(1).HPageBreaks(1).DragOff Direction:=xlUp,
RegionIndex:=1
End If
End Sub

Mike F








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
A problem with HPageBreaks NateBuckley Excel Programming 3 December 8th 08 11:36 PM
HPageBreaks.Add Stephen Plotnick Excel Programming 2 July 7th 07 01:41 AM
Is there no one who uses PageBreaks? HPageBreaks? GeorGeorGe Excel Worksheet Functions 0 February 11th 05 05:53 PM
HPageBreaks.Add GeorGeorGe Excel Worksheet Functions 0 February 9th 05 09:31 PM
Insert HPageBreaks Robert Christie[_3_] Excel Programming 2 November 15th 03 07:01 AM


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