?
Solved

Setting the Vertical Page Break in an Excel Macro

Posted on 2003-03-13
2
Medium Priority
?
1,109 Views
Last Modified: 2007-12-19
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
Comment
Question by:YeaYuh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
iaminit earned 120 total points
ID: 8131076
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
 
LVL 3

Author Comment

by:YeaYuh
ID: 8135649
Didn't occur to me that you had have it in PageBreak View.

Thanks
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question