Page break

Per_

Board Regular
Joined
Sep 16, 2011
Messages
90
Hello,

Is it possible in Excel that let you define an area that is not page breaked ?

Per
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Look under options.

My version of Excel has a tab with an option called "Page Break".

You can either check or un-check the box.

I guess un-checking it will eliminate the use of page Breaks.

You can also redefine the page break area under view.
 
Upvote 0
Well this small macro will alter the page break area.
My my version it works and you do not have to go into another view.

This changes the page break to range("$A$1:$I$24").

Try it and see if it works.

Code:
Sub ChangePageBreak()
   
    ActiveSheet.PageSetup.PrintArea = "$A$1:$I$24"
    
End Sub
 
Upvote 0
Thanks!!! I will se if I can manage what I want to do ... This is what I want to do.

I have a sheet that can change, people can add/remove lines by pushing buttons

Header 1
Text1
Text2
Test3
<---- Would like to get the page break here
Header 2
Test1
Test2
Test3

I would like to prevent to get a page break wihin the each group, so I would like the page break to come after Header 1 and Text 3.
 
Upvote 0
So you want the page break to shrink and expand with the list?

You could add a row and put the text "page break" in a cell (then white it out).

That would give you a consistent cell to refer to in some code.
As long as someone does not delete it.

Then you could refer to that cell in code.

Other than that the ranges would change and you would need to define the break relative to the second header as a cut off maybe.
Or end of data (though end of data would stop at a blank cell).

Just a few ideas.

Cheers
 
Upvote 0
Ok here is something that may you a bit.
I am assuming you have A4 paper and you only need to change the
horizontal page break.

A4 ends roughly at column I, but if you only need a horizontal break then it doesn't matter.

I entered the text "Page Break" into a cell in column "I", the text will move up and down as the rows shrinks and expands.

This code simply looks through column "I" and then finds the "Page Break" cell.

The code then adds the address of that cell to the page break address on the new line.



Warning: If the code does not find "Page Break" the code will go into a never ending loop,
so you might want to add something to stop it if it doesn't find the cell (so if someone removes a column the code will not find it).

Not the most eloquent of solutions but might get you started.

Cheers


Code:
Sub ChangePageBreak()

   Application.ScreenUpdating = False
   Range("I1").Select
   
   Do Until ActiveCell.Value = "Page Break"
   ActiveCell.Offset(1, 0).Select
   Loop
   pg = ActiveCell.Address

     'MsgBox CStr(pg)

   ActiveSheet.PageSetup.PrintArea = "$A$1:" + pg
    
End Sub

oh yeah and the msgbox is commented out, but its good to use just to see what the code is grabbing (or use the "Locals Window" and step through the code with F8).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,261
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top