Make only one vertical page break

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Make only one vertical page break

Post by YasserKhalil »

Hello everyone
I am trying to adjust the page breaks by code and as for the vertical page break I used this recorded line

Code: Select all

ws.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
For some files it works but doesn't work for other files ( I am looping through closed workbooks to adjust them)
How can I delete all the vertical page breaks and let only one vertical break before column L?

I tried this

Code: Select all

ws.VPageBreaks.Add ws.Range("L1")
This line doesn't throw errors but doesn't do what I want to do ..

YasserKhalil
PlatinumLounger
Posts: 4911
Joined: 31 Aug 2016, 09:02

Re: Make only one vertical page break

Post by YasserKhalil »

These two lines solved the probelm

Code: Select all

                            ws.VPageBreaks(1).Location = ws.Range("L1")
                            ws.VPageBreaks(1).DragOff Direction:=XlDirection.xlToRight, RegionIndex:=1
Found at this link
https://bettersolutions.com/excel/layou ... t-area.htm

User avatar
StuartR
Administrator
Posts: 12577
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Make only one vertical page break

Post by StuartR »

Thank you for sharing the solution
StuartR