ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   How do I... (https://www.excelbanter.com/excel-worksheet-functions/144124-how-do-i.html)

rneaul

How do I...
 
I want to develope a spreadsheet that I can use to keep a running total of
information in one cell...
example on moday I sell 10 units and input 10 in cell C1
on Tuesday I sell 2 units... I want to type 2 into cell C1 and have it
return 12 (10 + 2)

can this be done?

Gary''s Student

How do I...
 
Paste the following subs in the worksheet code area:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("C1"), Target) Is Nothing Then
Exit Sub
End If
Application.EnableEvents = False
Target.Value = Target.Value + oldvalue
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("C1"), Target) Is Nothing Then
Exit Sub
End If
oldvalue = Target.Value
End Sub


Paste the following single line in a standard module:

Public oldvalue As Integer
--
Gary''s Student - gsnu200724


"rneaul" wrote:

I want to develope a spreadsheet that I can use to keep a running total of
information in one cell...
example on moday I sell 10 units and input 10 in cell C1
on Tuesday I sell 2 units... I want to type 2 into cell C1 and have it
return 12 (10 + 2)

can this be done?


Gord Dibben

How do I...
 
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 and the same caveats as above.

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

OR go with the gnu's code and again have no paper trail or method of correction
for mis-entered numbers.


Gord Dibben Excel MVP


On Fri, 25 May 2007 09:40:02 -0700, rneaul
wrote:

I want to develope a spreadsheet that I can use to keep a running total of
information in one cell...
example on moday I sell 10 units and input 10 in cell C1
on Tuesday I sell 2 units... I want to type 2 into cell C1 and have it
return 12 (10 + 2)

can this be done?




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com