Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
I need to know if there is a way to create a formula that will allow me to
enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. |
#2
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
At the bottom there is a formula solution turning on iterations
http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. |
#3
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
And make note of the caveat about having no "audit trail" for error
checking. Gord Dibben MS Excel MVP On Wed, 28 Oct 2009 08:27:59 -0700, "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html |
#4
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
OK. This is great- it can be done!
Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . |
#5
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Here you go
http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . |
#6
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
OK. Finally got back on this little project and got it to work. Now how can
I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . |
#7
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . |
#8
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Really appreciate all the help you guys have given. I'd still be at square
one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . |
#9
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Poor testing on my part.
I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . |
#10
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Give this a try
Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . |
#11
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Just a note...........
Does not trap for errors created by user entering text string. If you need that post back. Gord On Wed, 11 Nov 2009 12:20:07 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Give this a try Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . |
#12
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
I'm starting to feel bad because I keep bothering you about this.
If I did this right (which I wouldn't swear to) I copy & pasted this to my worksheet and couldn't get it to work. Is that what I was supposed to do, or am I missing something here? Thanks again. "Gord Dibben" wrote: Just a note........... Does not trap for errors created by user entering text string. If you need that post back. Gord On Wed, 11 Nov 2009 12:20:07 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Give this a try Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . . |
#13
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
First of all, what you want to do is fraught with peril.
You have no way of trouble-shooting for incorrect data entry..........no paper trail to check. Why do you need the cell accumulator in that range of cells? Maybe there is something else that could be done? But.............the two events I posted will be pasted into the worksheet module...........right-click on sheet tab and "View Code". Paste into that module. When you select a cell in the range D6:K36 and that cell has a number value the value will be stored as "oldval". Enter a new number in the cell and it will be added to "oldval" in that cell. i,e, D6 is 10 Select D6 and enter 23 D6 will become 33 Gord On Wed, 11 Nov 2009 19:39:02 -0800, Brad Grow wrote: I'm starting to feel bad because I keep bothering you about this. If I did this right (which I wouldn't swear to) I copy & pasted this to my worksheet and couldn't get it to work. Is that what I was supposed to do, or am I missing something here? Thanks again. "Gord Dibben" wrote: Just a note........... Does not trap for errors created by user entering text string. If you need that post back. Gord On Wed, 11 Nov 2009 12:20:07 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Give this a try Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . . |
#14
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
Gord:
Great- I got it to work! One more question and this will be over. If an error comes up(due to a mistake on my part) it seems that the event stops working. How do I restart it? I understand your concern about having an accumulator of this size. This is one of those situations where this fits my purpose perfectly. This application use fairly small numbers and is not that critical- a small mistake here or there just won't end the world in this case. Thank you again for your help. Hopefully next time I come up with a little project like this I'll have a little more VBA knowlege and won't have to bother you! "Gord Dibben" wrote: First of all, what you want to do is fraught with peril. You have no way of trouble-shooting for incorrect data entry..........no paper trail to check. Why do you need the cell accumulator in that range of cells? Maybe there is something else that could be done? But.............the two events I posted will be pasted into the worksheet module...........right-click on sheet tab and "View Code". Paste into that module. When you select a cell in the range D6:K36 and that cell has a number value the value will be stored as "oldval". Enter a new number in the cell and it will be added to "oldval" in that cell. i,e, D6 is 10 Select D6 and enter 23 D6 will become 33 Gord On Wed, 11 Nov 2009 19:39:02 -0800, Brad Grow wrote: I'm starting to feel bad because I keep bothering you about this. If I did this right (which I wouldn't swear to) I copy & pasted this to my worksheet and couldn't get it to work. Is that what I was supposed to do, or am I missing something here? Thanks again. "Gord Dibben" wrote: Just a note........... Does not trap for errors created by user entering text string. If you need that post back. Gord On Wed, 11 Nov 2009 12:20:07 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Give this a try Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . . . |
#15
![]()
Posted to microsoft.public.excel.newusers
|
|||
|
|||
![]()
The one worksheet_change event has a trap to re-enable events if an error
occurs. I had remmed out that line when testing and forgot to unrem it. Try this version of the change_event Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Application.IsNumber(.Value) Then 'checks for text .Value = .Value + oldval End If End With End If ws_exit: oldval = "" 'clears oldval Application.EnableEvents = True End Sub Revised selection_change to account for selection value being text string. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then If Application.IsNumber(Target.Value) Then oldval = Target.Value Else oldval = "" End If End If End Sub Gord On Sat, 14 Nov 2009 07:21:02 -0800, Brad Grow wrote: Gord: Great- I got it to work! One more question and this will be over. If an error comes up(due to a mistake on my part) it seems that the event stops working. How do I restart it? I understand your concern about having an accumulator of this size. This is one of those situations where this fits my purpose perfectly. This application use fairly small numbers and is not that critical- a small mistake here or there just won't end the world in this case. Thank you again for your help. Hopefully next time I come up with a little project like this I'll have a little more VBA knowlege and won't have to bother you! "Gord Dibben" wrote: First of all, what you want to do is fraught with peril. You have no way of trouble-shooting for incorrect data entry..........no paper trail to check. Why do you need the cell accumulator in that range of cells? Maybe there is something else that could be done? But.............the two events I posted will be pasted into the worksheet module...........right-click on sheet tab and "View Code". Paste into that module. When you select a cell in the range D6:K36 and that cell has a number value the value will be stored as "oldval". Enter a new number in the cell and it will be added to "oldval" in that cell. i,e, D6 is 10 Select D6 and enter 23 D6 will become 33 Gord On Wed, 11 Nov 2009 19:39:02 -0800, Brad Grow wrote: I'm starting to feel bad because I keep bothering you about this. If I did this right (which I wouldn't swear to) I copy & pasted this to my worksheet and couldn't get it to work. Is that what I was supposed to do, or am I missing something here? Thanks again. "Gord Dibben" wrote: Just a note........... Does not trap for errors created by user entering text string. If you need that post back. Gord On Wed, 11 Nov 2009 12:20:07 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Give this a try Option Explicit Dim oldval As Variant Const WS_RANGE As String = "D6:K36" Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then oldval = Target.Value 'store value of selected cell End If End Sub Private Sub Worksheet_Change(ByVal Target As Range) 'On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target .Value = .Value + oldval End With End If ws_exit: Application.EnableEvents = True End Sub Gord On Wed, 11 Nov 2009 10:09:37 -0800, Gord Dibben <gorddibbATshawDOTca wrote: Poor testing on my part. I will try to come up with something that works over a range of cells. In the meantime hang in.........someone else may post a solution. Gord On Tue, 10 Nov 2009 19:31:25 -0800, Brad Grow wrote: Really appreciate all the help you guys have given. I'd still be at square one with this if it wasn't for you. Gord; I was actually referring to having the original accumulator work in many cells independently of each other. This code seems to make cells A1 thru A10 Accumulate in each cell but then as you go down the column they are summing themselves up as well. Does that make sense? I just need each cell to be an accumulator for itself. My actual range would be D6 through K36. So basically I need to make the original McGimpsey accumulator apply for this range. Thanks again for your help. "Gord Dibben" wrote: Private Sub Worksheet_Change(ByVal Target As Excel.Range) Static dAccumulator As Double Const WS_RANGE As String = "A1:A10" 'adjust range to suit. If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then With Target If Not IsEmpty(.Value) And IsNumeric(.Value) Then dAccumulator = dAccumulator + .Value Else dAccumulator = 0 End If Application.EnableEvents = False .Value = dAccumulator Application.EnableEvents = True End With End If End Sub Should pose no problem with a larger range. Gord Dibben MS Excel MVP On Mon, 9 Nov 2009 17:48:01 -0800, Brad Grow wrote: OK. Finally got back on this little project and got it to work. Now how can I make this work for more than one cell on a worksheet? I have played with it a little bit and I can make it work anywhere on the worksheet, but only one spot. Also is there any potential problems by having it apply to a range of cells? Thank you agaun for your time and assistance. "Peo Sjoblom" wrote: Here you go http://www.mvps.org/dmcritchie/excel/install.htm -- Regards, Peo Sjoblom "Brad Grow" wrote in message ... OK. This is great- it can be done! Pretty new at this so what do I do with this code? Copy and paste somewhere? Thanks! "Peo Sjoblom" wrote: At the bottom there is a formula solution turning on iterations http://www.mcgimpsey.com/excel/accumulator.html -- Regards, Peo Sjoblom "Brad Grow" <Brad wrote in message ... I need to know if there is a way to create a formula that will allow me to enter multiple values in a cell at different times and this formula will sum there values. Example: I would enter 10 in cell B3. An hour later I might enter 25 also in cell B3. After the second entry I would want it to automaticaly display 35. Is this possible and how would it be done? Thanks for your help. . . . . . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
formula question | Excel Worksheet Functions | |||
formula question | Excel Worksheet Functions | |||
formula question? | Excel Worksheet Functions | |||
Newbie Question - Subtraction Formula Question | Excel Discussion (Misc queries) | |||
Formula question | Excel Worksheet Functions |