Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to run a macro once a particular cell is modified. How to
detect that? Is there any way to do that other than selectionchange? Selection change doesn't give the previous value of the modified cell I guess. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need two macros:
I am using cell Z100 as an example 1. first set up a value in Z100 2. enter and run the following macro: Public v As Variant Sub sistence() v = Range("Z100").Value End Sub 3. finally enter the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Set t = Target Set r = Range("Z100") If Intersect(r, t) Is Nothing Then Exit Sub MsgBox (v & Chr(10) & t.Value) v = t.Value End Sub each time Z100 is changed, both the old and new values are displayed. -- Gary''s Student - gsnu200769 " wrote: I want to run a macro once a particular cell is modified. How to detect that? Is there any way to do that other than selectionchange? Selection change doesn't give the previous value of the modified cell I guess. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Instead of calling a separate macro, I think you can automate the entire
process like this... Public V As Variant Private Sub Worksheet_Change(ByVal Target As Range) If Intersect(Target, Range("Z100")) Is Nothing Then Exit Sub ' Your code goes here... MsgBox for example purposes only MsgBox "Old Value: " & V & Chr(10) & "New Value: " & Target.Value ' Make this the last statement in this event procedure V = Target.Value End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Not Intersect(Target, Range("Z100")) Is Nothing Then V = Target.Value End Sub Rick "Gary''s Student" wrote in message ... You need two macros: I am using cell Z100 as an example 1. first set up a value in Z100 2. enter and run the following macro: Public v As Variant Sub sistence() v = Range("Z100").Value End Sub 3. finally enter the following event macro in the worksheet code area: Private Sub Worksheet_Change(ByVal Target As Range) Set t = Target Set r = Range("Z100") If Intersect(r, t) Is Nothing Then Exit Sub MsgBox (v & Chr(10) & t.Value) v = t.Value End Sub each time Z100 is changed, both the old and new values are displayed. -- Gary''s Student - gsnu200769 " wrote: I want to run a macro once a particular cell is modified. How to detect that? Is there any way to do that other than selectionchange? Selection change doesn't give the previous value of the modified cell I guess. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
IF Statement Modifications | Excel Worksheet Functions | |||
turn off excel cell modifications? | Excel Discussion (Misc queries) | |||
CF sheet sub modifications | Excel Programming | |||
When content of a cell changes, content of another deletes | Excel Programming | |||
modifications on the code | Excel Programming |