ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   page break automatic macro (https://www.excelbanter.com/excel-programming/435792-page-break-automatic-macro.html)

yepidu

page break automatic macro
 
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.

883 456789 john wayne 2.25 25.00
883 123456 john wayne 1.75 22.50

-------------------------------------------------
*** 47.50
--------------------------------------------------

887 789123 Steven Segal 3.45 34.50
887 345678 Steven Segal 4.45 44.50

I would like to see the line when column "A" changes, but after space and
after total.

--
yepidu


All times are GMT +1. The time now is 10:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com