I have the following code below which works great, it adds the sum of the cells if they are 0. What I want now is to add a horizontal page break below the cell the sum is contained in the code below.
![]()
Dim lngLastRow As Long, _ lngFormulaRowStart As Long, _ lngFormulaRowEnd As Long Dim rngCell As Range lngLastRow = Cells(Rows.Count, "R").End(xlUp).Row + 1 lngFormulaRowStart = 2 lngFormulaRowEnd = 600 For Each rngCell In Range("R2:R" & lngLastRow) If Len(rngCell.Value) = 0 Then Worksheets(1).HPageBreaks(1).Location = Worksheets(1).rngCell.Location lngFormulaRowEnd = rngCell.Row - 1 rngCell.Formula = "=SUM(R" & lngFormulaRowStart & ":R" & lngFormulaRowEnd & ")" lngFormulaRowStart = rngCell.Offset(1, 0).Row lngFormulaRowEnd = rngCell.Offset(1, 0).Row End If Next rngCell











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks