Here's some sample code for column C:
This works for the same number of cells as used in column A - up to the page break:
Sub test()
Application.Calculation = xlCalculationManual
Sheets("Sheet1").Select
For Each r In Range("C1:C" & Cells(Rows.Count, "A").End(xlUp).Row)
If r.Rows.PageBreak <> xlNone Then
MsgBox "page break on " & r.Row
Exit For
End If
r.FormulaR1C1 = "=(RC[-2]+RC[-1])*2"
Next
Application.Calculation = xlCalculationAutomatic
End Sub
This one sounds like what you are after:
Sub test()
Application.Calculation = xlCalculationManual
Sheets("Sheet1").Select
For Each r In Range("C:C")
If r.Rows.PageBreak <> xlNone Then
MsgBox "page break on " & r.Row
Exit For
End If
r.FormulaR1C1 = "=(RC[-2]+RC[-1])*2"
Next
Application.Calculation = xlCalculationAutomatic
End Sub
You can duplicate the main part of the code changing the "Range" to the appropriate column and the formula to match what you are after.
BTW You can comment out or remove the message box, I just used it to show that it had "found" a page break.
Bookmarks