Running total of single cell.

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.
 
B

Bob Phillips

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.
 
R

RSnyder

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top