Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to detect cell content modifications?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to detect cell content modifications?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to detect cell content modifications?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
IF Statement Modifications Workbook Excel Worksheet Functions 9 February 19th 09 01:55 PM
turn off excel cell modifications? Fredrated Excel Discussion (Misc queries) 1 February 8th 08 07:22 AM
CF sheet sub modifications Max Excel Programming 3 January 11th 08 12:47 PM
When content of a cell changes, content of another deletes [email protected] Excel Programming 4 October 26th 07 08:17 PM
modifications on the code George Excel Programming 3 October 9th 07 07:11 PM


All times are GMT +1. The time now is 02:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"