• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1122
  • Last Modified:

Setting the Vertical Page Break in an Excel Macro

Right now I have a workbook with several sheets in it.  I run a macro that imports all data into the sheets and then highlights rows based on criteria, then it autoformats all the rows length.   When this happens the Vertical Page Break gets set.  I would like a way to either get rid of all the Vertical Page breaks on a sheet or how to set them all to the far right column.

Excel gave me this code when I recorded a Macro but it doesn't work in my macro, it gives me Run-time Error 1004:  
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
1 Solution
You have to be in pagebreak view for this to work.
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
ActiveWindow.View = xlNormalView
YeaYuhAuthor Commented:
Didn't occur to me that you had have it in PageBreak View.


Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now