PC Review


Reply
Thread Tools Rate Thread

break page based on specific conditions

 
 
Amarjeey
Guest
Posts: n/a
 
      15th Apr 2009
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 With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      15th Apr 2009
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 Before:=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

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      15th Apr 2009
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 Before:=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 With Quote
 
Amarjeey
Guest
Posts: n/a
 
      16th Apr 2009
Thank you very much. This is what i needed.
--
Amarjeet Kr. Sahay


"Mike H" wrote:

> 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 Before:=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

 
Reply With Quote
 
Amarjeey
Guest
Posts: n/a
 
      16th Apr 2009
Thanks you very much. This is what i needed.
--
Amarjeet Kr. Sahay


"Jacob Skaria" wrote:

> 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 Before:=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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page break based on value of sort field T.Yaya Microsoft Access Reports 1 13th Mar 2008 11:50 PM
Inserting HTML into a page based on conditions RSH Microsoft VB .NET 1 27th Apr 2006 12:26 AM
How do you page break on a specific field in an Access Report? =?Utf-8?B?aWdpZHR0YW0=?= Microsoft Access Reports 1 14th Mar 2005 08:08 PM
Page Break based on Dates Dan Microsoft Excel Programming 1 10th Mar 2005 07:37 PM
Page Break based on a Condition =?Utf-8?B?SmVmZg==?= Microsoft Access Reports 1 2nd Feb 2005 02:15 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:53 AM.