Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Locate changed cells with Worksheet_Calculate()

Hi,

I have some problem when using Worksheet_Calculate(), I want to write some
line to make cells change color when its value change after recalculate, I
use Worksheet_Calculate() but don't know how to locate the changed cells. For
Worksheet_Change(), we use Target.address to locate the changed cells
address, Do anyone know how to do the same thing with Worksheet_Calculate()?

Thanks alot.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Locate changed cells with Worksheet_Calculate()

Use static variables to keep track of the previous values of the cells you
are interested in.

Each time the Calculate Event occurs, the code would compare the values in
the static variables to the values in the cells.

This way the changed cell can be detected.
--
Gary''s Student - gsnu200831


"FourLegSpider" wrote:

Hi,

I have some problem when using Worksheet_Calculate(), I want to write some
line to make cells change color when its value change after recalculate, I
use Worksheet_Calculate() but don't know how to locate the changed cells. For
Worksheet_Change(), we use Target.address to locate the changed cells
address, Do anyone know how to do the same thing with Worksheet_Calculate()?

Thanks alot.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Locate changed cells with Worksheet_Calculate()

Thanks, I think it should work, actually I am using something like
yahoo_quote functions download stock quote from yahoo , when the price
go up, only the affected cell turn green, when the price go down, only
the affected turn red.

If use static variables, the main problem is
1)I don't know how many lines there will be.
2)if I change the price column to another column, I need to change the
code every time.



Gary''s Student wrote:
Use static variables to keep track of the previous values of the cells you
are interested in.

Each time the Calculate Event occurs, the code would compare the values in
the static variables to the values in the cells.

This way the changed cell can be detected.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,058
Default Locate changed cells with Worksheet_Calculate()

For the second problem, consider assigning a Defined Name to the price
column. That way, if you add/remove columns, your code can track the price
column automatically.
--
Gary''s Student - gsnu200832


"SaltyBall" wrote:

Thanks, I think it should work, actually I am using something like
yahoo_quote functions download stock quote from yahoo , when the price
go up, only the affected cell turn green, when the price go down, only
the affected turn red.

If use static variables, the main problem is
1)I don't know how many lines there will be.
2)if I change the price column to another column, I need to change the
code every time.



Gary''s Student wrote:
Use static variables to keep track of the previous values of the cells you
are interested in.

Each time the Calculate Event occurs, the code would compare the values in
the static variables to the values in the cells.

This way the changed cell can be detected.


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5
Default Locate changed cells with Worksheet_Calculate()

actually, I am new to excel vba, can you give some more hint about
"assigning a Defined Name to the price column"

do you mean use a variable as the name of the column variable? is it
possible in excel vba?

Thank you very much

Gary''s Student wrote:
For the second problem, consider assigning a Defined Name to the price
column. That way, if you add/remove columns, your code can track the price
column automatically.

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
worksheet_calculate code Jase Excel Discussion (Misc queries) 1 October 29th 08 08:17 PM
How do I locate merged cells jben001 Excel Discussion (Misc queries) 4 April 26th 07 09:57 PM
worksheet_calculate enyaw Excel Discussion (Misc queries) 2 January 26th 07 01:16 PM
worksheet_calculate enyaw Excel Discussion (Misc queries) 0 January 26th 07 08:14 AM
Infinite loop using Worksheet_Calculate Parker Excel Discussion (Misc queries) 2 November 3rd 06 12:25 PM


All times are GMT +1. The time now is 10:36 PM.

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"