View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Jacob Skaria Jacob Skaria is offline
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