Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Insert page breaks every 50 rows but do not include hidden rows

Hi there,

Is there a method to put page breaks in the used range every 50 rows but
exclude any hidden rows in the count of rows.

Example: a sheet with 200 rows of data and row 25 to 39 and 50 to 74 are
hidden. The first page break should then appear at row 90 and the second one
at row 140 etc.

Any help much appreciated.
--
Regards,

Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Insert page breaks every 50 rows but do not include hidden rows

Sub pformt()
k = 0
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
nFirstRow = r.Row
For n = nFirstRow To nLastRow
If Cells(n, "A").EntireRow.Hidden Then
Else
k = k + 1
End If
If k = 51 Then
k = 1
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=Cells(n, "A")
End If
Next
End Sub
--
Gary's Student
gsnu200710


"Martin" wrote:

Hi there,

Is there a method to put page breaks in the used range every 50 rows but
exclude any hidden rows in the count of rows.

Example: a sheet with 200 rows of data and row 25 to 39 and 50 to 74 are
hidden. The first page break should then appear at row 90 and the second one
at row 140 etc.

Any help much appreciated.
--
Regards,

Martin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Insert page breaks every 50 rows but do not include hidden rows

Hi There

I'm not sure exactly what it is you want to do with the sheet but it
would sound like you want to print it??? if so you could try
something like the following to process it for you what it does is
creates a new sheet then copies all the visible rows to it and set
your page breaks from there.

Private Sub CommandButton1_Click()
With Sheets.Add
.Name = "Filtered Sheet"
Sheets("sheet1").
[a1:a200].SpecialCells(xlCellTypeVisible).EntireRow.Copy
Sheets("Filtered Sheet").Range("A1").PasteSpecial
End With
Sheets("Filtered Sheet").Rows(50).PageBreak = xlPageBreakManual
Sheets("Filtered Sheet").Rows(100).PageBreak =
xlPageBreakManual
Sheets("Filtered Sheet").Rows(150).PageBreak = xlPageBreakManual
End Sub

This might not be what you are looking for but it may be of some help
to you.

Thanks

S

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Insert page breaks every 50 rows but do not include hidden rows

Maybe something like this:

Option Explicit
Sub testme()
Dim iRow As Long
Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")
With wks
.ResetAllPageBreaks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No visible cells!"
Exit Sub
End If

iRow = 0
For Each myCell In myRng.Cells
iRow = iRow + 1
If iRow 1 Then
If iRow Mod 50 = 1 Then
.HPageBreaks.Add befo=myCell
End If
End If
Next myCell
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Martin wrote:

Hi there,

Is there a method to put page breaks in the used range every 50 rows but
exclude any hidden rows in the count of rows.

Example: a sheet with 200 rows of data and row 25 to 39 and 50 to 74 are
hidden. The first page break should then appear at row 90 and the second one
at row 140 etc.

Any help much appreciated.
--
Regards,

Martin


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Insert page breaks every 50 rows but do not include hidden row

Thank you so much!
--
Regards,

Martin


"Gary''s Student" wrote:

Sub pformt()
k = 0
Set r = ActiveSheet.UsedRange
nLastRow = r.Rows.Count + r.Row - 1
nFirstRow = r.Row
For n = nFirstRow To nLastRow
If Cells(n, "A").EntireRow.Hidden Then
Else
k = k + 1
End If
If k = 51 Then
k = 1
ActiveWindow.SelectedSheets.HPageBreaks.Add Befo=Cells(n, "A")
End If
Next
End Sub
--
Gary's Student
gsnu200710


"Martin" wrote:

Hi there,

Is there a method to put page breaks in the used range every 50 rows but
exclude any hidden rows in the count of rows.

Example: a sheet with 200 rows of data and row 25 to 39 and 50 to 74 are
hidden. The first page break should then appear at row 90 and the second one
at row 140 etc.

Any help much appreciated.
--
Regards,

Martin



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Insert page breaks every 50 rows but do not include hidden row

Thank you so much!
--
Regards,

Martin


"Dave Peterson" wrote:

Maybe something like this:

Option Explicit
Sub testme()
Dim iRow As Long
Dim myCell As Range
Dim myRng As Range
Dim wks As Worksheet

Set wks = Worksheets("sheet1")
With wks
.ResetAllPageBreaks
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)) _
.Cells.SpecialCells(xlCellTypeVisible)
On Error GoTo 0

If myRng Is Nothing Then
MsgBox "No visible cells!"
Exit Sub
End If

iRow = 0
For Each myCell In myRng.Cells
iRow = iRow + 1
If iRow 1 Then
If iRow Mod 50 = 1 Then
.HPageBreaks.Add befo=myCell
End If
End If
Next myCell
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm


Martin wrote:

Hi there,

Is there a method to put page breaks in the used range every 50 rows but
exclude any hidden rows in the count of rows.

Example: a sheet with 200 rows of data and row 25 to 39 and 50 to 74 are
hidden. The first page break should then appear at row 90 and the second one
at row 140 etc.

Any help much appreciated.
--
Regards,

Martin


--

Dave Peterson

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
Excel: how to insert page breaks between all the rows at once? Kim Excel Discussion (Misc queries) 1 June 25th 08 09:37 PM
Ignore page breaks for hidden rows T Kirtley Excel Discussion (Misc queries) 1 September 26th 06 06:26 PM
How do I get rid of auto pg breaks in doc with hidden rows in Exce Annie777057 Excel Discussion (Misc queries) 1 July 12th 06 07:57 PM
Creating a counter that does not include hidden rows TechMGR Excel Discussion (Misc queries) 1 April 4th 05 10:11 PM
Copy Rows and insert these rows before a page break AQ Mahomed Excel Programming 0 June 8th 04 09:09 AM


All times are GMT +1. The time now is 05:38 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"