Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default macro and automatic page break

I need to insert a page break when 2 conditions are met.

I currently have:
Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
If Range("D" & IngRow) < Range("D" & IngRow - 1) Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End

But I also need consider if column F is greater than 0, insert page break
after row

--
yepidu
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default macro and automatic page break

Adjust to suit:

Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
'Added criteria
If Range("D" & IngRow) < Range("D" & IngRow - 1) And _
Range("F"&IngRow) 0 Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End


--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"yepidu" wrote:

I need to insert a page break when 2 conditions are met.

I currently have:
Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
If Range("D" & IngRow) < Range("D" & IngRow - 1) Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End

But I also need consider if column F is greater than 0, insert page break
after row

--
yepidu

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default macro and automatic page break

Thank you I will try that.
--
yepidu


"Luke M" wrote:

Adjust to suit:

Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
'Added criteria
If Range("D" & IngRow) < Range("D" & IngRow - 1) And _
Range("F"&IngRow) 0 Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End


--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"yepidu" wrote:

I need to insert a page break when 2 conditions are met.

I currently have:
Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
If Range("D" & IngRow) < Range("D" & IngRow - 1) Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End

But I also need consider if column F is greater than 0, insert page break
after row

--
yepidu

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default macro and automatic page break

this didn't make any difference, I am still getting a page break before and
after the data in column F
--
yepidu


"yepidu" wrote:

Thank you I will try that.
--
yepidu


"Luke M" wrote:

Adjust to suit:

Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
'Added criteria
If Range("D" & IngRow) < Range("D" & IngRow - 1) And _
Range("F"&IngRow) 0 Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End


--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"yepidu" wrote:

I need to insert a page break when 2 conditions are met.

I currently have:
Sub PageBreak()
Dim IngRow As Long
For IngRow = 2 To Cells(Rows.Count, "D").End(xlUp).Row + 1
If Range("D" & IngRow) < Range("D" & IngRow - 1) Then
ActiveSheet.HPageBreaks.Add Befo=Range("F" & IngRow)
End If
Next

End

But I also need consider if column F is greater than 0, insert page break
after row

--
yepidu

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-page break automatic brookse Excel Discussion (Misc queries) 1 June 22nd 09 04:23 PM
Excel: How do you insert an automatic page break after each row? tjw Excel Discussion (Misc queries) 1 January 15th 08 10:21 PM
Cannot move an automatic page break financialsecretary Excel Discussion (Misc queries) 3 July 25th 07 05:06 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
Using macro for page break Sara Excel Discussion (Misc queries) 2 January 13th 05 09:29 PM


All times are GMT +1. The time now is 10:49 PM.

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"