Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel-page break automatic | Excel Discussion (Misc queries) | |||
Excel: How do you insert an automatic page break after each row? | Excel Discussion (Misc queries) | |||
Cannot move an automatic page break | Excel Discussion (Misc queries) | |||
Can I set an automatic page breaks to break every 40 lines? | Excel Discussion (Misc queries) | |||
Using macro for page break | Excel Discussion (Misc queries) |