Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default break page based on specific conditions

Hi,

Could anyone let me know how can i use page break based on specific
conditions? I need macro for this. For example, search for table in A1
column, wherever table word will found it should start new page break.

Please help me on this regards. Thanks.
--
Amarjeet Kr. Sahay
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default break page based on specific conditions

Hi,

This looks for a lower case 'a' in column A and inserts a page break after
every one.

Right click your sheet tab, view code and paste this in

Sub stance()
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
For x = 2 To lastrow
If Cells(x - 1, 1).Value = "a" Then
HPageBreaks.Add Befo=Cells(x, 1)
End If
Next
End Sub

Mike

"Amarjeey" wrote:

Hi,

Could anyone let me know how can i use page break based on specific
conditions? I need macro for this. For example, search for table in A1
column, wherever table word will found it should start new page break.

Please help me on this regards. Thanks.
--
Amarjeet Kr. Sahay

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default break page based on specific conditions

The below macro will go through column A and put a pagebreak whenever it
finds an entry "PageBreak" in Col A. Set the Security level to low/medium in
(Tools|Macro|Security). 'Launch VBE using short-key Alt+F11. . Insert a
module and paste the below code. Save. Get back to Workbook. Tools|Macro|Run
Macro1()

Sub Macro1()
lngLastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For lngRow = 1 To lngLastRow
If Range("A" & lngRow) = "PageBreak" Then
Sheets("Sheet1").HPageBreaks.Add Befo=Range("A" & lngRow)
End If
Next
End Sub

--
If this post helps click Yes
---------------
Jacob Skaria


"Amarjeey" wrote:

Hi,

Could anyone let me know how can i use page break based on specific
conditions? I need macro for this. For example, search for table in A1
column, wherever table word will found it should start new page break.

Please help me on this regards. Thanks.
--
Amarjeet Kr. Sahay

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 2007 Page Break Adjustments causes a page break each cell BKaufman Excel Worksheet Functions 2 September 10th 10 05:02 AM
Insert page break based on change in Cell Color? jp Excel Programming 0 February 18th 09 10:08 PM
Page break macro based on cell content / formula Dave Peterson Excel Programming 2 February 21st 08 03:02 PM
Page Break based on Dates Dan Excel Programming 1 March 10th 05 07:37 PM
adding a new page break to an existing page break Edward Letendre Excel Discussion (Misc queries) 1 March 6th 05 09:29 AM


All times are GMT +1. The time now is 05:25 AM.

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"