Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Subscript Out of Range ... Setting Page Breaks

Hi,

I recorded the macro below. But when I run it I get a "subscript out of
range" message. I would welcome any suggestions.

Sub Macro1()
'
' Macro1 Macro

Sheets("Variance").Select
ActiveSheet.ResetAllPageBreaks
Set ActiveSheet.VPageBreaks(1).Location = Range("AA1")
Set ActiveSheet.HPageBreaks(2).Location = Range("A397")
Set ActiveSheet.HPageBreaks(3).Location = Range("A389")
Set ActiveSheet.HPageBreaks(2).Location = Range("A332")
Set ActiveSheet.HPageBreaks(3).Location = Range("A518")
Set ActiveSheet.HPageBreaks(4).Location = Range("A691")
Range("B882").Select
Set ActiveSheet.HPageBreaks(5).Location = Range("A859")
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Subscript Out of Range ... Setting Page Breaks

I just recorded a macro to add page breaks and this is what was displayed

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
ActiveWindow.SelectedSheets.VPageBreaks.Add Befo=ActiveCell

I'm sure you can tweak that to get what you want.
--
HTH,
Barb Reinhardt



"manfareed" wrote:

Hi,

I recorded the macro below. But when I run it I get a "subscript out of
range" message. I would welcome any suggestions.

Sub Macro1()
'
' Macro1 Macro

Sheets("Variance").Select
ActiveSheet.ResetAllPageBreaks
Set ActiveSheet.VPageBreaks(1).Location = Range("AA1")
Set ActiveSheet.HPageBreaks(2).Location = Range("A397")
Set ActiveSheet.HPageBreaks(3).Location = Range("A389")
Set ActiveSheet.HPageBreaks(2).Location = Range("A332")
Set ActiveSheet.HPageBreaks(3).Location = Range("A518")
Set ActiveSheet.HPageBreaks(4).Location = Range("A691")
Range("B882").Select
Set ActiveSheet.HPageBreaks(5).Location = Range("A859")
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Subscript Out of Range ... Setting Page Breaks

Thanks ... I have got part of the answer
I have a problem with automatic page breaks. The Vertical page break in my
code was moving the automatic page break to "AA". I don't want to end up
with a manual page break at "AA" and an automatic page break at "AD"

"Barb Reinhardt" wrote:

I just recorded a macro to add page breaks and this is what was displayed

ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=ActiveCell
ActiveWindow.SelectedSheets.VPageBreaks.Add Befo=ActiveCell

I'm sure you can tweak that to get what you want.
--
HTH,
Barb Reinhardt



"manfareed" wrote:

Hi,

I recorded the macro below. But when I run it I get a "subscript out of
range" message. I would welcome any suggestions.

Sub Macro1()
'
' Macro1 Macro

Sheets("Variance").Select
ActiveSheet.ResetAllPageBreaks
Set ActiveSheet.VPageBreaks(1).Location = Range("AA1")
Set ActiveSheet.HPageBreaks(2).Location = Range("A397")
Set ActiveSheet.HPageBreaks(3).Location = Range("A389")
Set ActiveSheet.HPageBreaks(2).Location = Range("A332")
Set ActiveSheet.HPageBreaks(3).Location = Range("A518")
Set ActiveSheet.HPageBreaks(4).Location = Range("A691")
Range("B882").Select
Set ActiveSheet.HPageBreaks(5).Location = Range("A859")
End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting Page Breaks Ken Hudson Excel Discussion (Misc queries) 1 January 5th 10 08:47 PM
setting page breaks for whole spreadsheet to be consistent? Mickey Setting up and Configuration of Excel 1 May 15th 07 12:50 AM
setting page breaks. Rod[_2_] Excel Programming 3 May 23rd 06 12:28 AM
Setting page breaks (another) Ian W[_2_] Excel Programming 1 March 15th 05 12:23 PM
Are conditional formats available for setting page breaks? Nicky Armstrong Excel Discussion (Misc queries) 1 February 20th 05 03:51 PM


All times are GMT +1. The time now is 10:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"