ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Accumulator cells (https://www.excelbanter.com/excel-programming/361309-accumulator-cells.html)

tom

Accumulator cells
 
Hi all,
Is there a way to modify this code so that it applies to all rows instead of
just the indicated rows? For example....adding a value in D3 will be added to
F3...values added in D10 will be added to F10...and so on....in other words,
I'd like it to apply to the entire columns.

Thanks!

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub

cory

Accumulator cells
 
Tom,

Give this a try - the commented cells have been replaced by the one
immediately above:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Column = "4" Then
' If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value + .Value
' Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Column = "3" Then
' If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value - .Value
' Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


"Tom" wrote:

Hi all,
Is there a way to modify this code so that it applies to all rows instead of
just the indicated rows? For example....adding a value in D3 will be added to
F3...values added in D10 will be added to F10...and so on....in other words,
I'd like it to apply to the entire columns.

Thanks!

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


tom

Accumulator cells
 
That did it...
Thanks Cory!!!

"Cory" wrote:

Tom,

Give this a try - the commented cells have been replaced by the one
immediately above:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Column = "4" Then
' If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value + .Value
' Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Column = "3" Then
' If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value - .Value
' Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


"Tom" wrote:

Hi all,
Is there a way to modify this code so that it applies to all rows instead of
just the indicated rows? For example....adding a value in D3 will be added to
F3...values added in D10 will be added to F10...and so on....in other words,
I'd like it to apply to the entire columns.

Thanks!

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


Wendell A. Clark

Accumulator cells Multiple subsets - multiple accumulators
 
I've ben toying with a similair problem, I need to check the value of two
different rows of a subset of the entire spreadsheet and test to see if the
newer value is smaller than the previous value (the newer) value can be
detected by a date field in a cell on the row. their are 10 cells that I
need to test ultimately to return a percentage of the total quantity of
subsets that had smaller values .

I have tried pulling the data through an autofilter but the cell refrences
differ for each subset -- needles to say my beard is going gray trying to
fit the basic loop to the (varying) subset(s), then accumulating the totals
for each of the test categories.

Any ideas -- I'm vegging and lost -- thanks ;-)


--
Wendell A. Clark, BS
-------------------------------------

CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may
contain confidential and privileged information for the use of the
designated recipients named above. If you are not the intended recipient,
please notify us by reply e-mail. You are hereby notified that you have
received this communication in error and that any review, disclosure,
dissemination, distribution or copying of it or its contents is prohibited.
If you have received this communication in error, please destroy all copies
of this communication and any attachments. Contact the sender if it
continues.


"Cory" wrote in message
...
Tom,

Give this a try - the commented cells have been replaced by the one
immediately above:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Column = "4" Then
' If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value + .Value
' Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Column = "3" Then
' If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Cells(.Row, "F").Value = Cells(.Row, "F").Value - .Value
' Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub


"Tom" wrote:

Hi all,
Is there a way to modify this code so that it applies to all rows instead
of
just the indicated rows? For example....adding a value in D3 will be
added to
F3...values added in D10 will be added to F10...and so on....in other
words,
I'd like it to apply to the entire columns.

Thanks!

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Address(False, False) = ("D3") Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value + .Value
Application.EnableEvents = True
End If
End If
End With
With Target
If .Address(False, False) = "C3" Then
If IsNumeric(.Value) Then
Application.EnableEvents = False
Range("F3").Value = Range("F3").Value - .Value
Application.EnableEvents = True
End If
End If
End With
End Sub





All times are GMT +1. The time now is 12:59 AM.

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