Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default keeping a running total in a single cell

Is it possible to have numbers added to the same cell and have excel continue
to calculate the addition for me in that same cell......ex: I have the number
8 in cell d2 and I want to add the number 8 to that cell and have excel add
the 8 to the previous 8 for a total of 16 in the same cell.....the next time
I would add 5, and the total would be 21? Can this be done in a single cell?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default keeping a running total in a single cell

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,081
Default keeping a running total in a single cell

While Don's approach can solve your problem, keep in mind that you lose any
kind of audit trail. If you miskey a number, your running total is hosed and
there is nothing you can do but start all over. Matter of fact, even if you
DON'T miskey a number, you hav no way of validating that the running total is
correct.

In other words, what you want to accomplish isn't a recommended way of working


"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default keeping a running total in a single cell

thanks for the information, very much appreciated

"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default keeping a running total in a single cell

thanks for the reply

"Duke Carey" wrote:

While Don's approach can solve your problem, keep in mind that you lose any
kind of audit trail. If you miskey a number, your running total is hosed and
there is nothing you can do but start all over. Matter of fact, even if you
DON'T miskey a number, you hav no way of validating that the running total is
correct.

In other words, what you want to accomplish isn't a recommended way of working


"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default keeping a running total in a single cell

Don, again thanks for your help, but I'm having a little trouble following
what you put. When I right click the sheet tab (at the bottom of the page)
and select insert, it comes up with a general tab and a spreadsheet solutions
tab. Does the formula that you wrote below start Option Explicit???? Is
there a formula that I can just assign to that specific cell......sorry if
this doesn't make sense.

"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?




  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default keeping a running total in a single cell

This is NOT a formula. It is a macro. A formula will NOT do what you desire.
I forgot to include a step
right click sheet tabVIEW CODEcopy paste the code as written.
Although this WILL do what you said, Dukes comment is valid.

--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Don, again thanks for your help, but I'm having a little trouble following
what you put. When I right click the sheet tab (at the bottom of the page)
and select insert, it comes up with a general tab and a spreadsheet
solutions
tab. Does the formula that you wrote below start Option Explicit???? Is
there a formula that I can just assign to that specific cell......sorry if
this doesn't make sense.

"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?






  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default keeping a running total in a single cell

Are you sure you want to do this?

Think about it after reading the following.

You can have a cumulative total in a cell if you have a
separate source cell for adding a new total to the original.

Use at your own risk. I am Posting this just to show you how it can
be done, not as a good solution. You would be much better off to
have another column so you can keep track of past entries.

Goes like this: =IF(CELL("address")="$C$4",C4+D4,D4)

Enter this in cell D4 and then in ToolsOptionsCalculation check
Iterations and set to 1.

Now when you change the number in C4, D4 will accumulate.

Note 1. If C4 is selected and a calculation takes place anywhere in
the Application D4 will update even if no new number is entered in
C4. NOT GOOD.
Note 2. This operation is not recommended because you will have no
"paper trail" to follow. Any mistake in entering a new number in C4
cannot be corrected. NOT GOOD.

To clear out the accumulated total in D4 and start over, select D4
and EditEnter.

Check out Laurent Longre's MoreFunc.xla. Has a Function RECALL
which does what you want without the re-calculation problem, but
again there is no "paper trail" for back-checking in case of errors
in data input.

http://longre.free.fr/english/func_cats.htm

Also see John McGimpsey's site for VBA method.

http://www.mcgimpsey.com/excel/accumulator.html



Gord Dibben Excel MVP

On Tue, 22 Aug 2006 12:36:01 -0700, shrtdawg73
wrote:

Is it possible to have numbers added to the same cell and have excel continue
to calculate the addition for me in that same cell......ex: I have the number
8 in cell d2 and I want to add the number 8 to that cell and have excel add
the 8 to the previous 8 for a total of 16 in the same cell.....the next time
I would add 5, and the total would be 21? Can this be done in a single cell?


Gord Dibben MS Excel MVP
  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default keeping a running total in a single cell

thanks for the help. I think what you explained is more of what I'm looking
for.

if I use the formula " =IF(CELL("address")="$C$4",C4+D4,D4) " (does it go in
the cell exactly like that) I can add a number to C4 and D4 will reflect the
total? I hope I'm understanding this right? :o)

"Gord Dibben" wrote:

Are you sure you want to do this?

Think about it after reading the following.

You can have a cumulative total in a cell if you have a
separate source cell for adding a new total to the original.

Use at your own risk. I am Posting this just to show you how it can
be done, not as a good solution. You would be much better off to
have another column so you can keep track of past entries.

Goes like this: =IF(CELL("address")="$C$4",C4+D4,D4)

Enter this in cell D4 and then in ToolsOptionsCalculation check
Iterations and set to 1.

Now when you change the number in C4, D4 will accumulate.

Note 1. If C4 is selected and a calculation takes place anywhere in
the Application D4 will update even if no new number is entered in
C4. NOT GOOD.
Note 2. This operation is not recommended because you will have no
"paper trail" to follow. Any mistake in entering a new number in C4
cannot be corrected. NOT GOOD.

To clear out the accumulated total in D4 and start over, select D4
and EditEnter.

Check out Laurent Longre's MoreFunc.xla. Has a Function RECALL
which does what you want without the re-calculation problem, but
again there is no "paper trail" for back-checking in case of errors
in data input.

http://longre.free.fr/english/func_cats.htm

Also see John McGimpsey's site for VBA method.

http://www.mcgimpsey.com/excel/accumulator.html



Gord Dibben Excel MVP

On Tue, 22 Aug 2006 12:36:01 -0700, shrtdawg73
wrote:

Is it possible to have numbers added to the same cell and have excel continue
to calculate the addition for me in that same cell......ex: I have the number
8 in cell d2 and I want to add the number 8 to that cell and have excel add
the 8 to the previous 8 for a total of 16 in the same cell.....the next time
I would add 5, and the total would be 21? Can this be done in a single cell?


Gord Dibben MS Excel MVP

  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default keeping a running total in a single cell

Don meant right-click on the sheet tab and "View Code"

Paste his code into that sheet module.

I still do not recommend this accumulator method, but caveat emptor.


Gord Dibben MS Excel MVP

On Tue, 22 Aug 2006 14:27:02 -0700, shrtdawg73
wrote:

Don, again thanks for your help, but I'm having a little trouble following
what you put. When I right click the sheet tab (at the bottom of the page)
and select insert, it comes up with a general tab and a spreadsheet solutions
tab. Does the formula that you wrote below start Option Explicit???? Is
there a formula that I can just assign to that specific cell......sorry if
this doesn't make sense.

"Don Guillett" wrote:

right click sheet tabinsert thisSAVE now in cell a5 you can add it up

Option Explicit
Dim oldvalue As Double

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$A$5" Then
On Error GoTo fixit
Application.EnableEvents = False
If Target.Value = 0 Then oldvalue = 0
Target.Value = 1 * Target.Value + oldvalue
oldvalue = Target.Value
fixit:
Application.EnableEvents = True
End If
End Sub


--
Don Guillett
SalesAid Software

"shrtdawg73" wrote in message
...
Is it possible to have numbers added to the same cell and have excel
continue
to calculate the addition for me in that same cell......ex: I have the
number
8 in cell d2 and I want to add the number 8 to that cell and have excel
add
the 8 to the previous 8 for a total of 16 in the same cell.....the next
time
I would add 5, and the total would be 21? Can this be done in a single
cell?







  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default keeping a running total in a single cell

Yes

Enter the formula in D4.

Enter a number in C4, D4 will show that number.

Overwrite the number in C4 with another and D4 will accumulate.

You can use any two cells for the input and accumulator.

Just change the cell references.

Be sure to read all the caveats included with this method.


Gord


On Tue, 22 Aug 2006 15:38:02 -0700, shrtdawg73
wrote:

thanks for the help. I think what you explained is more of what I'm looking
for.

if I use the formula " =IF(CELL("address")="$C$4",C4+D4,D4) " (does it go in
the cell exactly like that) I can add a number to C4 and D4 will reflect the
total? I hope I'm understanding this right? :o)

"Gord Dibben" wrote:

Are you sure you want to do this?

Think about it after reading the following.

You can have a cumulative total in a cell if you have a
separate source cell for adding a new total to the original.

Use at your own risk. I am Posting this just to show you how it can
be done, not as a good solution. You would be much better off to
have another column so you can keep track of past entries.

Goes like this: =IF(CELL("address")="$C$4",C4+D4,D4)

Enter this in cell D4 and then in ToolsOptionsCalculation check
Iterations and set to 1.

Now when you change the number in C4, D4 will accumulate.

Note 1. If C4 is selected and a calculation takes place anywhere in
the Application D4 will update even if no new number is entered in
C4. NOT GOOD.
Note 2. This operation is not recommended because you will have no
"paper trail" to follow. Any mistake in entering a new number in C4
cannot be corrected. NOT GOOD.

To clear out the accumulated total in D4 and start over, select D4
and EditEnter.

Check out Laurent Longre's MoreFunc.xla. Has a Function RECALL
which does what you want without the re-calculation problem, but
again there is no "paper trail" for back-checking in case of errors
in data input.

http://longre.free.fr/english/func_cats.htm

Also see John McGimpsey's site for VBA method.

http://www.mcgimpsey.com/excel/accumulator.html



Gord Dibben Excel MVP

On Tue, 22 Aug 2006 12:36:01 -0700, shrtdawg73
wrote:

Is it possible to have numbers added to the same cell and have excel continue
to calculate the addition for me in that same cell......ex: I have the number
8 in cell d2 and I want to add the number 8 to that cell and have excel add
the 8 to the previous 8 for a total of 16 in the same cell.....the next time
I would add 5, and the total would be 21? Can this be done in a single cell?


Gord Dibben MS Excel MVP


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mileage Claim Formula johndavies New Users to Excel 4 August 14th 06 09:24 AM
How do I total range of cells that have checks in checkboxes? instructorjml Excel Discussion (Misc queries) 2 March 23rd 06 11:56 AM
substract cell F from cell H and total into cell I vadarpug Excel Worksheet Functions 1 October 31st 05 12:32 PM
substract cell F from cell H and total into cell I vadarpug New Users to Excel 1 October 31st 05 11:57 AM
how do i set up a single cell continual entry in excel to total f. mike@swallow Excel Discussion (Misc queries) 1 December 7th 04 12:29 PM


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"