Hi,
I have a small code that pastes in a formula to sum the cell through to P2 as long as there is a valve in the current cell. It loops for all values in the array. It works fine but instead of pasting the formula, is there a way of completing the sum function in VBA and only pasting the calculated value? Essentially it is creating a cumulative tally in column Q of the values in column P only if there is a value in column P. In the code startrow begins at 2 and loops with the total row count in the sheet
If Cells(startrow, "P") <> "" Then
Cells(startrow, "Q").Formula = "=SUM(P2:P" & startrow & ")"
End If
Cheers
I have a small code that pastes in a formula to sum the cell through to P2 as long as there is a valve in the current cell. It loops for all values in the array. It works fine but instead of pasting the formula, is there a way of completing the sum function in VBA and only pasting the calculated value? Essentially it is creating a cumulative tally in column Q of the values in column P only if there is a value in column P. In the code startrow begins at 2 and loops with the total row count in the sheet
If Cells(startrow, "P") <> "" Then
Cells(startrow, "Q").Formula = "=SUM(P2:P" & startrow & ")"
End If
Cheers