Running total of single cell.

  • Thread starter Thread starter Paul Schu
  • Start date Start date
P

Paul Schu

I have for example cell b1. I will input a number in B1
then later on input a new number in B1. How can
I keep a running total in just one cell. For example in
B1 my first input will be 12. This will then show up in
cell G1. Then later I will input 14 in B1 and now G1
will show as 26 the total of the two inputs.
 
Paul,

Easy with code

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
On Error GoTo ws_exit
If Not Intersect(Target, Range("B1")) Is Nothing Then
Range("G1").Value = Range("G1").Value + Range("B1").Value
End If

ws_exit:
Application.EnableEvents = True
End Sub


It goes in the worksheet code module, so got ot the sheet tab, right-click,
select View Code and paste this code in the code pane.
 
You can keep a running total if you use the cell input as
a calculator by pressing the equals key, plus key, or
minus key before entering any number but that would mean
that you would be following the first number with the next
number before pressing enter. If you are moving your
cursor to another location or you've made another formula
dependant upon the B1 cell you would need to use a macro
that will add B1 to the existing value in G1. Don't know
if that helps much but there it is anyway.
 
Back
Top