Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Detecting a change in a cell

This is just an outline of a possible method:

1. Capture the value of the target cell at the beginning of the procedure
and store it in a variable, exmpl: compVal = Range("D10").Value.

2. Incorporate an If ... Then statement at the end of each sub routine that
might change the value of cell D10, exmpl:

If Range("D10").Value < compVal Then
Opt = MsgBox "Range("D10") value has changed to " _
& Range("D10").Value, Run Macro?, vbYesNo, "Choose"
If Opt = vbYes Then
myMacro
End If
End If

3. If you will need to check the value again before the porcedure ends then
you could just reset the compVal value within the If...Then statement.

It is kind of a rustic way to do it. But it can work.

"Brad Stone" wrote:

Hi all,

I'm fairly new to VBA programming. I'm using Excel 2003. I need to
know when a particular cell (it's actually a single cell "range" called
MYRANGE) has changed. When I detect the change, I need to see if the
new numeric value in that cell is not zero; if it's non-zero then I need
to activate some code. Unfortunately that cell is changed via a
formula - so using Worksheet_Change is apparently not going to work.
That is, Worksheet_Change doesn't get triggered for cells of this type.

I tried using .OnTimer to repeatedly check the value of that cell, but
I couldn't get it to work very well.

It seems like there has got to be an easy way to trigger some code to
activate when a cell has changed (even for a cell that changes via a
formula). Thanks for any help!

-Brad


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
Cell value - detecting change tgmjf Excel Worksheet Functions 2 July 20th 06 08:12 PM
script detecting the change of active cell Jack Excel Programming 1 February 12th 04 01:59 AM
Detecting Input Change on User Form Don Wiss Excel Programming 3 December 2nd 03 02:09 AM
Detecting Worksheet change Tim[_14_] Excel Programming 2 July 10th 03 01:47 PM


All times are GMT +1. The time now is 09:34 AM.

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"