ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Auto Sum entries in a cell (https://www.excelbanter.com/excel-worksheet-functions/196312-auto-sum-entries-cell.html)

Mike

Auto Sum entries in a cell
 
Hi, let's say I entered 5 in A1 and then the next day I updated the cell to
6. Can Excel total these two entries in A1 to get a total of 11. I don't
want to use a separate cell to add up each entry.

Your help is greatly appreciated
--
Regards
Mike

Bernie Deitrick

Auto Sum entries in a cell
 
Mike,

Add this to a standard module

Option Explicit
Public myValue As Double


Add these two to the worksheet's codemodule

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
Target.Value = Target.Value + myValue
myValue = Target.Value
Application.EnableEvents = True
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$1" Then myValue = Target.Value
End Sub


Add this to the workbook's code module, changing the Sheet1 to the correct sheet name:

Private Sub Workbook_Open()
myValue = Worksheets("Sheet1").Range("A1").Value
End Sub

HTH,
Bernie
MS Excel MVP


"Mike" wrote in message
...
Hi, let's say I entered 5 in A1 and then the next day I updated the cell to
6. Can Excel total these two entries in A1 to get a total of 11. I don't
want to use a separate cell to add up each entry.

Your help is greatly appreciated
--
Regards
Mike




Gord Dibben

Auto Sum entries in a cell
 
Mike

Bernie's code will do the job, but you will have no "audit trail" in the
event of incorrect data input.

This can lead to problems.


Gord Dibben MS Excel MVP

On Fri, 25 Jul 2008 06:29:03 -0700, Mike
wrote:

Hi, let's say I entered 5 in A1 and then the next day I updated the cell to
6. Can Excel total these two entries in A1 to get a total of 11. I don't
want to use a separate cell to add up each entry.

Your help is greatly appreciated




All times are GMT +1. The time now is 07:29 AM.

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