Adding page Break with VBA

mattxu2006

New Member
Joined
Mar 25, 2011
Messages
37
HI.
I have been trying to write a macro to add a page break in Excel 2007, but I have had no success.

A friend recomended:
Columns("CC:CC").Select
ActiveWindow.SelectedSheets.Vpagebreaks.add Before:= ActiveCell

This has not had any affect when I have printed.

Have any suggestions?

Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Where do you want to add the Page break?

Your code above adds a Vertical page break in column CC which is a column WAAAY to the right.

This example will add a Horizontal page break at row 10
Code:
ActiveSheet.HPageBreaks.Add Before:=Rows(10)

This example will add a Vertical page break at Column G
Code:
ActiveSheet.VPageBreaks.Add Before:=Columns("G")
 
Upvote 0
howdy AlphaFrog
Column CC is one of the places that I would like to insert a Vertical Page Break.

Unfortunately, what you suggest isn't working either.
 
Upvote 0
howdy AlphaFrog
Column CC is one of the places that I would like to insert a Vertical Page Break.

Unfortunately, what you suggest isn't working either.

Mattxu2006, it is not working for you, because you need to change the view of your spreadsheet to pagebreak view before dealing with pagebreaks:
Code:
ActiveWindow.View = xlPageBreakPreview

Then, when you are done dealing with page breaks, switch back to normal view:
Code:
ActiveWindow.View = xlNormalView

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,543
Members
449,316
Latest member
sravya

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