Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Accumulator | Excel Worksheet Functions | |||
accumulator with other than one | Excel Worksheet Functions | |||
Adding an accumulator for multiple cells | Excel Worksheet Functions | |||
Please help fix my accumulator | Excel Programming | |||
Please help me get this accumulator working | Excel Programming |