Hello everyone.
I have a workbook with 50 + tabs and I use VBA to loop through and format each tab. Part of the VBA sets the workbook to page break view, drags the page breaks to the far right, and then switches back to normal view. This code takes the dotted blue line that runs vertically between two columns and drags it off to the far right (between column F and G). The code works great until it comes to a tab that does not have a dotted vertical blue line in page break view. I receive a Run-time error '9': Subscript out of range error message when this happens.
Any suggestions on how to: move to the next tab when this error occurs or how to modify the code below to set the page break between columns F and G?
Thanks in advance for your help.
Ben
I have a workbook with 50 + tabs and I use VBA to loop through and format each tab. Part of the VBA sets the workbook to page break view, drags the page breaks to the far right, and then switches back to normal view. This code takes the dotted blue line that runs vertically between two columns and drags it off to the far right (between column F and G). The code works great until it comes to a tab that does not have a dotted vertical blue line in page break view. I receive a Run-time error '9': Subscript out of range error message when this happens.
Any suggestions on how to: move to the next tab when this error occurs or how to modify the code below to set the page break between columns F and G?
Thanks in advance for your help.
Ben
Code:
' Change to page break view - drag off page breaks
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
' change to normal view
ActiveWindow.View = xlNormalView