View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Joerg Joerg is offline
external usenet poster
 
Posts: 138
Default How do I add/count numbers in the same cell in excel worksheet?

For a start, put following code into a module. When you run the
AddValueOnEnter macro, whatever value you enter will be added to the
existing value (your existing '127' will become '=127+50', so that you can
still trace your inputs). Run ResetEnter when you want to reset the ENTER
key to normal behaviour.

Cheers,
Joerg Mochikun


Public PresentValue As String

Sub AddValueOnEnter()
Application.OnKey "{ENTER}", "AddValue"
End Sub

Sub ResetEnter()
Application.OnKey "{ENTER}", ""
End Sub

Sub Addvalue()
On Error Resume Next
If Left(PresentValue, 1) < "=" Then PresentValue = "=" & PresentValue
ActiveCell.Formula = PresentValue & "+" & ActiveCell.Formula
PresentValue = ActiveCell.Formula
End Sub








"Scott" wrote in message
oups.com...
Probably the wisest way to use one cell to do this would be to put the
following in the cell:

=127

When you get a $50 receipt, change it to:

=127+50

When you get another receipt, say 34.95:

=127+50+34.95

The reason to do it this way is so that if you happen to make a mistake
when entering the value, you don't lose your previous data.

Scott

Brecken wrote:
How do I create a function or formula in acell to perform this

operation?
(i.e if I have the number 127 in a cell and want to to enter 50 into the

same
cell so that I get a sum of 177 in the same cell, how do I do this,

rather
than adding the 2 numbers in my head, and manually entering 177?) I am

doing
this for purposes of a budget and entering receipts. If the amount I've
spent on groceries is $127 up to the present time, and I want to add an
additional grocery receipt of $50, I want to be able to have the cell

add the
new entry, rather than adding the 50 in my head and enter $177.

Thanks!