Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Make page break every several lines automatically by VBA

Hello, is it possible to make page break by counting lines? I've
written a program to create graphs with comments. But every time EXCEL
just separate the page by the length of graphs. What I want is to make
page break between every 39 line and 40 line automatically. For
example, between 39 and 40, 78 and 79...etc.

By the way, the length of the graphs I created changes in a very little
range. But it is only the little change that make me cannot print
correctly.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Make page break every several lines automatically by VBA

Something like this :

Private Sub CommandButton1_Click()
Const HPageBreakSpacing As Long = 40
Const PagesToProcess As Long = 4
Dim WS As Worksheet
Dim i As Long

Set WS = ThisWorkbook.Worksheets(1)
With WS
.ResetAllPageBreaks
For i = 1 To PagesToProcess
.HPageBreaks.Add Cells(i * HPageBreakSpacing, 1)
Next
End With
End Sub

NickHK

wrote in message
ps.com...
Hello, is it possible to make page break by counting lines? I've
written a program to create graphs with comments. But every time EXCEL
just separate the page by the length of graphs. What I want is to make
page break between every 39 line and 40 line automatically. For
example, between 39 and 40, 78 and 79...etc.

By the way, the length of the graphs I created changes in a very little
range. But it is only the little change that make me cannot print
correctly.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Make page break every several lines automatically by VBA

Thank you very much, I've tried and it really works.

I am so surprised that your response comes so fast.

On 11ÔÂ9ÈÕ, ÏÂÎç2ʱ39·Ö, "NickHK" wrote:
Something like this :

Private Sub CommandButton1_Click()
Const HPageBreakSpacing As Long = 40
Const PagesToProcess As Long = 4
Dim WS As Worksheet
Dim i As Long

Set WS = ThisWorkbook.Worksheets(1)
With WS
.ResetAllPageBreaks
For i = 1 To PagesToProcess
.HPageBreaks.Add Cells(i * HPageBreakSpacing, 1)
Next
End With
End Sub

NickHK

wrote in glegroups.com...



Hello, is it possible to make page break by counting lines? I've
written a program to create graphs with comments. But every time EXCEL
just separate the page by the length of graphs. What I want is to make
page break between every 39 line and 40 line automatically. For
example, between 39 and 40, 78 and 79...etc.


By the way, the length of the graphs I created changes in a very little
range. But it is only the little change that make me cannot print
correctly.- Òþ²Ø±»ÒýÓÃÎÄ×Ö -- ÏÔʾÒýÓõÄÎÄ×Ö -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Make page break every several lines automatically by VBA

how about something like this. just change the range and sheet names

Sub test()
Dim cell As Range
Dim ws As Worksheet
Set ws = Worksheets("sheet1")
For Each cell In Range("a1:A400")
With ws
If cell.Row Mod 39 = 0 Then
.HPageBreaks.Add befo=cell.Offset(1, 0)
End If
End With
Next
End Sub

--


Gary


wrote in message
ps.com...
Hello, is it possible to make page break by counting lines? I've
written a program to create graphs with comments. But every time EXCEL
just separate the page by the length of graphs. What I want is to make
page break between every 39 line and 40 line automatically. For
example, between 39 and 40, 78 and 79...etc.

By the way, the length of the graphs I created changes in a very little
range. But it is only the little change that make me cannot print
correctly.



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
How to remove page break lines in normal view? [email protected] Excel Discussion (Misc queries) 6 April 4th 23 02:19 PM
Page Break Lines in Excel 2007 Ostate Excel Discussion (Misc queries) 2 February 24th 07 04:48 PM
Can I set an automatic page breaks to break every 40 lines? Kennbu Excel Discussion (Misc queries) 1 June 15th 06 05:59 PM
automatically put in page break after 14 lines. Steved Excel Programming 2 August 2nd 05 10:07 AM
Hatched page break lines Hotbird[_2_] Excel Programming 2 February 20th 04 02:36 PM


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