Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default Event Sub when one specific cell changes

Hi,

I am using Excel 2007. I have written a VBA Sub that I want to be called
any time the value in one particular cell is changed.

I know I can do this by creating a Worksheet_Change() Sub and checking the
'Target' Range parameter to see if the changed cell is the one I want to
watch. The drawback of this is that this Sub gets called any time *any* cell
is changed. In my case, this will get called alot because I have a value in
another cell that changes once per second (it displays the current time).

I was wondering if there is an event Sub other than Worksheet_Change() that
would be called only when the one cell I want to watch changes?

Thanks in advance,
Paul Kraemer
--
Paul Kraemer
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 100
Default Event Sub when one specific cell changes

Paul asked "I know how to do X, but can I do Y?", and you answered
"Here's how to do X".

Having said that, I'm pretty sure the answer is no, you have to just
check in the Worksheet_Change sub.

Phil Hibbs.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Event Sub when one specific cell changes

There is not an event that would function like Celll_Change. It would
be nice, but it isn't so. It is possible (in theory) to use a set of
classes to handle the Worksheet events for only specific cells, but
that wouldn't buy much, either in performance or simplicity.
Basically, you're stuck with Worksheet_Change:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case LCase(Target.Address(False, False))
Case "a1"
Debug.Print "do something for A1"
Case "c3"
Debug.Print "do something for C3"
' and so on for each cell in question
End Select
End Sub

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Wed, 10 Feb 2010 05:30:01 -0800, Paul Kraemer
wrote:

Hi,

I am using Excel 2007. I have written a VBA Sub that I want to be called
any time the value in one particular cell is changed.

I know I can do this by creating a Worksheet_Change() Sub and checking the
'Target' Range parameter to see if the changed cell is the one I want to
watch. The drawback of this is that this Sub gets called any time *any* cell
is changed. In my case, this will get called alot because I have a value in
another cell that changes once per second (it displays the current time).

I was wondering if there is an event Sub other than Worksheet_Change() that
would be called only when the one cell I want to watch changes?

Thanks in advance,
Paul Kraemer

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
How to run an event upon changing the value of a specific cell? Wael Fathy Excel Worksheet Functions 1 February 23rd 10 02:04 PM
Event when a specific cell changes mohavv Excel Discussion (Misc queries) 1 August 25th 08 10:29 PM
Change Event on a Specific Cell Sashi Excel Worksheet Functions 3 July 20th 07 11:12 PM
If event When a specific cell changes nuclearjack Excel Programming 1 August 19th 06 06:48 AM
Worksheet_Change Event triggered off specific cell ExcelMonkey[_142_] Excel Programming 2 June 7th 04 03:33 AM


All times are GMT +1. The time now is 11:41 AM.

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

About Us

"It's about Microsoft Excel"