• 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
0
YeaYuh
Asked:
YeaYuh
1 Solution
 
iaminitCommented:
You have to be in pagebreak view for this to work.
Try:
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
ActiveWindow.View = xlNormalView
0
 
YeaYuhAuthor Commented:
Didn't occur to me that you had have it in PageBreak View.

Thanks
0

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