View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
hnyb1 hnyb1 is offline
external usenet poster
 
Posts: 29
Default Sum to the last row in vba

O.K. this code is working to put in a formula that sums a certain number of
rows every time the if statement is true, however I need to alter the code to
sum a variable number of rows, i.e. one cell down : end (xldown). Is that
possible?

Sub cleanup2()
Worksheets("Raw Data").Activate
With ActiveSheet
For i = 10 To 479
If Cells(i, 13) = "1" And Cells(i + 1, 13) = "" Then
Cells(i, 20).Select
ActiveCell.FormulaR1C1 = "=SUM(R[1]C:R[7]C)"
End If
Next
End With

End Sub

THanks in advance,
Holly