Adding a number to itself


Posted by Cathy on October 30, 2000 1:13 PM

If I have the number 15 in a column and then I enter the 5 how do I get the column to automatically update itself to show 20? So everytime I enter a number, I want it to add itself to the number that was there before?

Help please.

Cathy



Posted by Ivan Moala on October 31, 2000 12:02 AM

Cathy, one way to do this is via event handler
code.....The change event for the sheet.

eg. say sheet1 and the cell is A1 then use this
code;

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Static A As Double

If Target.Address = "$A$1" Then
Application.EnableEvents = False
Target.Value = A + Target.Value
A = Range("a1").Value
Application.EnableEvents = True
End If
End Sub

Ivan