Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default RAND() Won't Trigger Worksheet_Change

I put a random number cell on my worksheet, and I want to be able to run some
code in the Worksheet_Change routine every time that cell is updated. I have
discovered that when that cell updates, Excel is not considering it a
"change" - the event is not triggered.

Any ideas as to why this is, and how I can work around it? I know the code
is working, because if I type "=RAND()" in that cell again and hit Enter, the
event is triggered because I changed the formula of the cell. Also, if I
just type a number of text into the cell, the event is triggered.

Thanks,

Eric


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default RAND() Won't Trigger Worksheet_Change

Worksheet_change catches your typing.

Maybe you want to use to use the worksheet_calculate event???

egun wrote:

I put a random number cell on my worksheet, and I want to be able to run some
code in the Worksheet_Change routine every time that cell is updated. I have
discovered that when that cell updates, Excel is not considering it a
"change" - the event is not triggered.

Any ideas as to why this is, and how I can work around it? I know the code
is working, because if I type "=RAND()" in that cell again and hit Enter, the
event is triggered because I changed the formula of the cell. Also, if I
just type a number of text into the cell, the event is triggered.

Thanks,

Eric


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default RAND() Won't Trigger Worksheet_Change

You need to use a different event, the Worksheet Calculate event.
--
Gary''s Student - gsnu200832


"egun" wrote:

I put a random number cell on my worksheet, and I want to be able to run some
code in the Worksheet_Change routine every time that cell is updated. I have
discovered that when that cell updates, Excel is not considering it a
"change" - the event is not triggered.

Any ideas as to why this is, and how I can work around it? I know the code
is working, because if I type "=RAND()" in that cell again and hit Enter, the
event is triggered because I changed the formula of the cell. Also, if I
just type a number of text into the cell, the event is triggered.

Thanks,

Eric


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default RAND() Won't Trigger Worksheet_Change

Hadn't thought about Worksheet_Calculate. I'll give it a try.

Thanks guys!


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 88
Default RAND() Won't Trigger Worksheet_Change

Okay, just realized this - the Worksheet_Calculate routine does not have
"Target" as an argument. How do I know if my specific cell has been updated?
Since it's a volatile function, is it safe to assume it changed any time the
worksheet is recalculated?

Thanks again,

Eric



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default RAND() Won't Trigger Worksheet_Change

For the cell with =rand(), yep. Since it's volatile.

If you had a cell that contained a formula that may not change during a
recalculation, you'd have to keep track of that cell's value your own self.

egun wrote:

Okay, just realized this - the Worksheet_Calculate routine does not have
"Target" as an argument. How do I know if my specific cell has been updated?
Since it's a volatile function, is it safe to assume it changed any time the
worksheet is recalculated?

Thanks again,

Eric


--

Dave Peterson
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
Run VBA code only worksheet change, but don't trigger worksheet_change event based on what the code does ker_01 Excel Programming 6 October 3rd 08 09:45 PM
Trigger Macro by Worksheet_Change JSnow Excel Discussion (Misc queries) 5 October 2nd 08 06:27 PM
data validation list does not trigger worksheet_change event ivory_kitten Excel Programming 1 October 17th 06 04:25 AM
Worksheet_Change wont Trigger Scorcel[_2_] Excel Programming 1 September 1st 04 06:43 AM
Worksheet_Change sub does not trigger a called macro herman Excel Programming 3 February 8th 04 08:30 PM


All times are GMT +1. The time now is 03:38 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"