Accumulator cells

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,

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
 
That did it...
Thanks Cory!!!

Cory said:
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top