Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How to insert page break after every 10 rows?

Could anybody help me with the VBA-code needed ub this? I have 3000 rows in
one sheet and I would like to print only 10 rows for each paper.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How to insert page break after every 10 rows?

One way:

Option Explicit
Sub testme()
Dim myCell As Range
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long

With Worksheets("Sheet1")
FirstRow = 11
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

.ResetAllPageBreaks

For iRow = FirstRow To LastRow Step 10
.Cells(iRow, "A").PageBreak = xlPageBreakManual
Next iRow
End With
End Sub

I put the first pagebreak before row 11. I used column A to find out the last
used row.

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

kativa wrote:

Could anybody help me with the VBA-code needed ub this? I have 3000 rows in
one sheet and I would like to print only 10 rows for each paper.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default How to insert page break after every 10 rows?

Thank you very much! The way doesn't matter until the code works and this
did. You made my day :=)

-Kate

"Dave Peterson" kirjoitti:

One way:

Option Explicit
Sub testme()
Dim myCell As Range
Dim iRow As Long
Dim LastRow As Long
Dim FirstRow As Long

With Worksheets("Sheet1")
FirstRow = 11
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

.ResetAllPageBreaks

For iRow = FirstRow To LastRow Step 10
.Cells(iRow, "A").PageBreak = xlPageBreakManual
Next iRow
End With
End Sub

I put the first pagebreak before row 11. I used column A to find out the last
used row.

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

kativa wrote:

Could anybody help me with the VBA-code needed ub this? I have 3000 rows in
one sheet and I would like to print only 10 rows for each paper.


--

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
insert page break when there is a change in the row value [email protected] Excel Worksheet Functions 3 July 14th 06 07:20 PM
cannot insert page break tsmanz Excel Discussion (Misc queries) 2 December 5th 05 05:45 PM
Automatically insert page break every 6 rows in excel doc Icetea Excel Discussion (Misc queries) 1 October 10th 05 11:55 AM
Insert Page Break Question Don Excel Discussion (Misc queries) 1 June 10th 05 02:05 PM
Insert Page Break Don Excel Discussion (Misc queries) 3 June 9th 05 08:32 PM


All times are GMT +1. The time now is 03:29 PM.

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

About Us

"It's about Microsoft Excel"