Home |
Search |
Today's Posts |
#1
|
|||
|
|||
macro for auto sum
I am fairly new to macros in general. Does anyone have an existing macro
that I can use which will auto sum the existing value in a cell with a new value added to it......i.e. if cell B10 has a value in it of 55 and I type in 5 into cell B10 it will auto sum and leave 60 as the new cell contents ? the actual code would really help...or just steps to do this. thanks |
#2
|
|||
|
|||
Option Explicit
Private prevValue Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False With Target If .Address = "$B$6" Then .Value = prevValue + .Value End If prevValue = .Value End With ws_exit: Application.EnableEvents = True End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) With Target If .Address = "$B$6" Then prevValue = .Value End If End With End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH RP (remove nothere from the email address if mailing direct) "ahemani" wrote in message ... I am fairly new to macros in general. Does anyone have an existing macro that I can use which will auto sum the existing value in a cell with a new value added to it......i.e. if cell B10 has a value in it of 55 and I type in 5 into cell B10 it will auto sum and leave 60 as the new cell contents ? the actual code would really help...or just steps to do this. thanks |
#3
|
|||
|
|||
Can be done as Bob points out, but do you really want to do this?
Where is your "paper trail" so's you can keep track of entries? What do you do when someone enters 9 instead of 10? If you want to have an accumulator cell.....lotsa luck. Gord Dibben Excel MVP On Wed, 27 Jul 2005 22:09:01 -0700, "ahemani" wrote: I am fairly new to macros in general. Does anyone have an existing macro that I can use which will auto sum the existing value in a cell with a new value added to it......i.e. if cell B10 has a value in it of 55 and I type in 5 into cell B10 it will auto sum and leave 60 as the new cell contents ? the actual code would really help...or just steps to do this. thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Make Alignment options under format cells available as shortcut | Excel Discussion (Misc queries) | |||
Help with macro looping and color query function | Excel Discussion (Misc queries) | |||
Playing a macro from another workbook | Excel Discussion (Misc queries) | |||
Date macro | Excel Discussion (Misc queries) | |||
Macro and If Statement | Excel Discussion (Misc queries) |