View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
JR_06062005[_2_] JR_06062005[_2_] is offline
external usenet poster
 
Posts: 34
Default Page Break: Format Row

In the following macro I have inserted a print preview to reset the
horizontal page break counter in the spreadsheet. Without this accomodation
I can only run the macro once. The second time I run it, I get an out of
range error.

Is there another way to reset the horizontal page break so that each time
the macro runs it starts recognizing the horizontal page breaks from the
beginnging of the spreadsheet?

Sub LineFormatAtPageBreak()
Dim oHPgbr As HPageBreak

ActiveWindow.SelectedSheets.PrintPreview

For Each oHPgbr In ActiveSheet.HPageBreaks
MsgBox "Other row page break at:" & oHPgbr.Location.Address
' Format row at page break
Next
End Sub