PC Review


Reply
Thread Tools Rate Thread

On change event for specific cells

 
 
=?Utf-8?B?aGVhZGx5?=
Guest
Posts: n/a
 
      1st Nov 2007
I am familiar with the worksheet on change event, but can I use it to narrow
down so that the code runs only based on changes to a specific range of
cells, not knowing beforehand what the current value of any of those cells
are, only if the value in the cells in a specific range is changed? TIA
 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      1st Nov 2007
Two ways. The change event has an argument Target. That is the cell or cells
that were changed. So based on that...

if target.address = "$A$1" then
msgbox target.address
end if

'**or**

if not intersect(target, range("A1:B10")) is nothing then
msgbox target.address
end if

if the cell that you wnat to detect a chnge in is a formula then that gets a
bit trickier but it can still be done. Reply back if that is the case...
--
HTH...

Jim Thomlinson


"headly" wrote:

> I am familiar with the worksheet on change event, but can I use it to narrow
> down so that the code runs only based on changes to a specific range of
> cells, not knowing beforehand what the current value of any of those cells
> are, only if the value in the cells in a specific range is changed? TIA

 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      1st Nov 2007
hi there

a way to do it would be to use intersect

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Not Intersect(Target, Range("A1:A10")) Is Nothing Then

MsgBox "I am part of your set range"

Else

MsgBox "Where as i am not"

End If

End Sub

hope it helps

S


 
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
how to change the value of some cells, if one specific cell value isthere. Softarcade Microsoft Excel Misc 0 26th Feb 2008 04:49 AM
Font colour change based on Rgb codes given in specific cells =?Utf-8?B?Z3JlZW5jZWNpbA==?= Microsoft Excel Programming 1 2nd Sep 2007 09:59 PM
Change Event on a Specific Cell =?Utf-8?B?U2FzaGk=?= Microsoft Excel Worksheet Functions 3 20th Jul 2007 11:12 PM
change event on specific cell rather than worksheet =?Utf-8?B?ZnJlbmRhYnJlbmRhMQ==?= Microsoft Excel Misc 10 21st Sep 2006 03:37 AM
Macro to only change specific cells =?Utf-8?B?VEhU?= Microsoft Excel Programming 1 2nd May 2005 05:21 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:25 PM.