Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Making a function somewhat volatile.

Hi,

Suppose my function makes a reference to a range (named "MyRange"). So, in a
way, the function depends on it. Is there a way to cause the function to
recalculate when the vlaue of "MyRange" changes? I don't want to make
volatile since too many cells depend on it and "MyRange" changes
infrequently.

Thanks!

Bura



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Making a function somewhat volatile.

Hi Bura

That is the default behavior. Try this:

Function Half(WholeValue As Double) As Double
Half = WholeValue / 2
End Function

In Cell B1:
=Half(A1)

and then in A1 any number or any formula. It recalculates whenever A1 does.

So why doesn't yours ? I can only guess; you have something hardcoded into
the function instead of passed to it? Please post it for suggestions.

HTH. Best wishes Harald

"Bura Tino" skrev i melding
...
Hi,

Suppose my function makes a reference to a range (named "MyRange"). So, in

a
way, the function depends on it. Is there a way to cause the function to
recalculate when the vlaue of "MyRange" changes? I don't want to make
volatile since too many cells depend on it and "MyRange" changes
infrequently.

Thanks!

Bura





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Making a function somewhat volatile.


"Harald Staff" wrote in message
...
Hi Bura

That is the default behavior. Try this:

Function Half(WholeValue As Double) As Double
Half = WholeValue / 2
End Function

In Cell B1:
=Half(A1)

and then in A1 any number or any formula. It recalculates whenever A1

does.

So why doesn't yours ? I can only guess; you have something hardcoded into
the function instead of passed to it? Please post it for suggestions.


Yes, it is hardcoded. That's what I was trying to convey by saying
"references". How about

Function ValueOfA1() as String
ValueOfA1 = Worksheets("MyWorksheet").Range("A1")
End Function

I use this in an add-in to getthe value of a cell that belong to the add-in.
Why this is necessary is another question. What I want to achieve is that if
the value A1 changes, all cells which depend on ValueOfA1 are recalculated.

HTH. Best wishes Harald

"Bura Tino" skrev i melding
...
Hi,

Suppose my function makes a reference to a range (named "MyRange"). So,

in
a
way, the function depends on it. Is there a way to cause the function to
recalculate when the vlaue of "MyRange" changes? I don't want to make
volatile since too many cells depend on it and "MyRange" changes
infrequently.

Thanks!

Bura







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Making a function somewhat volatile.

Hi Bura,

The only methods of getting a function into the dependency tree so that it
recalculates are to make it volatile or change a cell it refersto in its
argument list or reenter the formula that contains the function.

Charles
______________________
Decision Models
FastExcel Version 2 now available.
www.DecisionModels.com/FxlV2WhatsNew.htm

"Bura Tino" wrote in message
...

"Harald Staff" wrote in message
...
Hi Bura

That is the default behavior. Try this:

Function Half(WholeValue As Double) As Double
Half = WholeValue / 2
End Function

In Cell B1:
=Half(A1)

and then in A1 any number or any formula. It recalculates whenever A1

does.

So why doesn't yours ? I can only guess; you have something hardcoded

into
the function instead of passed to it? Please post it for suggestions.


Yes, it is hardcoded. That's what I was trying to convey by saying
"references". How about

Function ValueOfA1() as String
ValueOfA1 = Worksheets("MyWorksheet").Range("A1")
End Function

I use this in an add-in to getthe value of a cell that belong to the

add-in.
Why this is necessary is another question. What I want to achieve is that

if
the value A1 changes, all cells which depend on ValueOfA1 are

recalculated.

HTH. Best wishes Harald

"Bura Tino" skrev i melding
...
Hi,

Suppose my function makes a reference to a range (named "MyRange").

So,
in
a
way, the function depends on it. Is there a way to cause the function

to
recalculate when the vlaue of "MyRange" changes? I don't want to make
volatile since too many cells depend on it and "MyRange" changes
infrequently.

Thanks!

Bura









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
Would like help making a function Sarah H.[_2_] Excel Discussion (Misc queries) 4 November 16th 09 04:14 PM
Today - volatile function dhstein Excel Discussion (Misc queries) 5 May 25th 09 03:12 PM
is MATCH a volatile function? Dave F Excel Discussion (Misc queries) 3 January 31st 07 07:05 PM
why is the INDIRECT function volatile? Dave F Excel Worksheet Functions 2 October 25th 06 02:10 PM
Application.Volatile messing up other function itchyII Excel Programming 1 April 1st 04 04:31 PM


All times are GMT +1. The time now is 12:50 PM.

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"