PC Review


Reply
Thread Tools Rate Thread

How to detect cell content modifications?

 
 
yajiv.vijay@gmail.com
Guest
Posts: n/a
 
      14th Feb 2008
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 With Quote
 
 
 
 
Gary''s Student
Guest
Posts: n/a
 
      14th Feb 2008
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


"(E-Mail Removed)" 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 With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      14th Feb 2008
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" <(E-Mail Removed)> wrote in message
news:EFA2D9D3-43CD-42E4-B511-(E-Mail Removed)...
> 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
>
>
> "(E-Mail Removed)" 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
turn off excel cell modifications? Fredrated Microsoft Excel Misc 1 8th Feb 2008 07:22 AM
Detect Windows Registry Modifications NormanWilburn@gmail.com Windows XP General 1 13th Apr 2006 06:26 AM
Can sumif detect text strings or detect if a dollar sign $ is in a cell? MollyDavis Microsoft Excel Misc 4 17th Apr 2004 11:45 PM
Can sumif detect text strings or detect if a dollar sign $ is in a cell? MollyDavis Microsoft Excel Worksheet Functions 4 17th Apr 2004 11:45 PM
Highlighting cell content based on content of another cell bkarlstrom Microsoft Excel Worksheet Functions 3 4th Dec 2003 02:22 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:40 AM.