Cumulative Total Within Cells


Posted by Mike on November 14, 2001 6:38 AM

This just HAS to be easy, but I can't figure it out....EXCEL rookie

I need a formula for keeping a running total in one particular cell. For example, in cell E8, I initially input the number 20, I then come back a week later and add 80, and then add 23 a few days after that. This is where I want the cell to show the cumulative total of 123.
Help Help, thank you.



Posted by Dan on November 14, 2001 9:57 AM

I think this needs to be done in code. Does it ever need to be reset back to zero?
If not try:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim RunningTotal As Long
RunningTotal = Range("B1").Value
If Not Intersect(Target, Range("A1")) Is Nothing Then
Range("B1").Value = RunningTotal + Range("A1").Value
End If
End Sub

This puts the running total in B1, with values entered in A1. If you need it to reset, let me know. One workaround to resetting it back to zero is just to enter a negative number in A1 that will sum B1 to zero. Otherwise, more code can be written. HTH.