Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Scope limit of user written Excel Functions

I had the requirement to write a function, which would be embedded in a cell
that could modify the values of other cells in the same worksheet. However,
the function kept returning the #Value error. I traced through the function
using Msgbox and established that the error was being caused the moment the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value to
the cell in which it is embedded and they have no constructs to modify the
contents of other cells, there must be a scope limit on user functions that
prevents a user defined function from modifing any cell but the one in which
it is embedded.

I have since found a work-around to this problem using a few programs tricks
and now the same code that caused the error works correctly, modifying other
cells. However, I would still like to know if anyone: has some familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the scope
limit?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Scope limit of user written Excel Functions

confirmed. It is not allowed. As such, there is no setting that makes it
possible.

Suspect you are using some combination of Events and embedded functions.


http://support.microsoft.com/kb/170787/en-us
Description of Limitations of Custom Functions
--
Regards,
Tom Ogilvy


"mickey" wrote:

I had the requirement to write a function, which would be embedded in a cell
that could modify the values of other cells in the same worksheet. However,
the function kept returning the #Value error. I traced through the function
using Msgbox and established that the error was being caused the moment the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value to
the cell in which it is embedded and they have no constructs to modify the
contents of other cells, there must be a scope limit on user functions that
prevents a user defined function from modifing any cell but the one in which
it is embedded.

I have since found a work-around to this problem using a few programs tricks
and now the same code that caused the error works correctly, modifying other
cells. However, I would still like to know if anyone: has some familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the scope
limit?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 112
Default Scope limit of user written Excel Functions

Thanks Tom,

I appreciate the confirmation.

"Tom Ogilvy" wrote:

confirmed. It is not allowed. As such, there is no setting that makes it
possible.

Suspect you are using some combination of Events and embedded functions.


http://support.microsoft.com/kb/170787/en-us
Description of Limitations of Custom Functions
--
Regards,
Tom Ogilvy


"mickey" wrote:

I had the requirement to write a function, which would be embedded in a cell
that could modify the values of other cells in the same worksheet. However,
the function kept returning the #Value error. I traced through the function
using Msgbox and established that the error was being caused the moment the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value to
the cell in which it is embedded and they have no constructs to modify the
contents of other cells, there must be a scope limit on user functions that
prevents a user defined function from modifing any cell but the one in which
it is embedded.

I have since found a work-around to this problem using a few programs tricks
and now the same code that caused the error works correctly, modifying other
cells. However, I would still like to know if anyone: has some familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the scope
limit?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Scope limit of user written Excel Functions

I had the exact same question. It seems to me that this is one of the really
really basic things that a user would want to do in a function written for a
spread sheet i.e. modify spread sheet cells. It is hard to believe that it
is disallowed. You can view the cells but you cant modify them. I have
noticed that the exact same code placed in a macro will allow you to modify a
cell but that that code placed in a function called from a cell as you
describe will not allow you to modify the same cell. Go figure.
I am interested in how you circumvented this problem as I want to be able to
modify spread sheet cells from a user defined function as I am sure lots of
people would want to do. Can you explain further?

"mickey" wrote:

I had the requirement to write a function, which would be embedded in a cell
that could modify the values of other cells in the same worksheet. However,
the function kept returning the #Value error. I traced through the function
using Msgbox and established that the error was being caused the moment the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value to
the cell in which it is embedded and they have no constructs to modify the
contents of other cells, there must be a scope limit on user functions that
prevents a user defined function from modifing any cell but the one in which
it is embedded.

I have since found a work-around to this problem using a few programs tricks
and now the same code that caused the error works correctly, modifying other
cells. However, I would still like to know if anyone: has some familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the scope
limit?

Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Scope limit of user written Excel Functions

In order to calculate worksheet formulae Excel needs to know which cells
"depend" on which other cells. If it allowed updating of "random" cells
from inside a UDF then it would might be possible to calculate a sheet
correctly (since it would need to be able to scan your UDF code to determine
dependent cells).

So this restriction is not unreasonable.

Tim


"AnnapolisStar" wrote in message
...
I had the exact same question. It seems to me that this is one of the
really
really basic things that a user would want to do in a function written for
a
spread sheet i.e. modify spread sheet cells. It is hard to believe that
it
is disallowed. You can view the cells but you cant modify them. I have
noticed that the exact same code placed in a macro will allow you to
modify a
cell but that that code placed in a function called from a cell as you
describe will not allow you to modify the same cell. Go figure.
I am interested in how you circumvented this problem as I want to be able
to
modify spread sheet cells from a user defined function as I am sure lots
of
people would want to do. Can you explain further?

"mickey" wrote:

I had the requirement to write a function, which would be embedded in a
cell
that could modify the values of other cells in the same worksheet.
However,
the function kept returning the #Value error. I traced through the
function
using Msgbox and established that the error was being caused the moment
the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value
to
the cell in which it is embedded and they have no constructs to modify
the
contents of other cells, there must be a scope limit on user functions
that
prevents a user defined function from modifing any cell but the one in
which
it is embedded.

I have since found a work-around to this problem using a few programs
tricks
and now the same code that caused the error works correctly, modifying
other
cells. However, I would still like to know if anyone: has some
familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the scope
limit?

Thanks





  #6   Report Post  
Posted to microsoft.public.excel.programming
Tim Tim is offline
external usenet poster
 
Posts: 145
Default Scope limit of user written Excel Functions

Typo:

If it allowed updating of "random" cells from inside a UDF then it might
*not* be possible to calculate a sheet correctly

Tim



"Tim Williams" <timjwilliams at gmail dot com wrote in message
...
In order to calculate worksheet formulae Excel needs to know which cells
"depend" on which other cells. If it allowed updating of "random" cells
from inside a UDF then it would might be possible to calculate a sheet
correctly (since it would need to be able to scan your UDF code to
determine dependent cells).

So this restriction is not unreasonable.

Tim


"AnnapolisStar" wrote in message
...
I had the exact same question. It seems to me that this is one of the
really
really basic things that a user would want to do in a function written
for a
spread sheet i.e. modify spread sheet cells. It is hard to believe that
it
is disallowed. You can view the cells but you cant modify them. I have
noticed that the exact same code placed in a macro will allow you to
modify a
cell but that that code placed in a function called from a cell as you
describe will not allow you to modify the same cell. Go figure.
I am interested in how you circumvented this problem as I want to be able
to
modify spread sheet cells from a user defined function as I am sure lots
of
people would want to do. Can you explain further?

"mickey" wrote:

I had the requirement to write a function, which would be embedded in a
cell
that could modify the values of other cells in the same worksheet.
However,
the function kept returning the #Value error. I traced through the
function
using Msgbox and established that the error was being caused the moment
the
function tried to modify a foreign cell. After some experimentation it
appears that, just as Excel's own built-in functions only return a value
to
the cell in which it is embedded and they have no constructs to modify
the
contents of other cells, there must be a scope limit on user functions
that
prevents a user defined function from modifing any cell but the one in
which
it is embedded.

I have since found a work-around to this problem using a few programs
tricks
and now the same code that caused the error works correctly, modifying
other
cells. However, I would still like to know if anyone: has some
familiarity
with this issue, can confirm that there is a scope limit in user defined
functions; and knows of a way to change that property to remove the
scope
limit?

Thanks





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
Excel fails to update call to user-written function. Jim Luedke New Users to Excel 9 August 28th 09 12:46 AM
How do I use functions that I have written in Excel formulas Gita_B Excel Worksheet Functions 2 March 5th 09 07:51 PM
Restrict-Filter-Limit-Validate user input in Excel Dr. Thom Excel Discussion (Misc queries) 0 January 22nd 06 08:06 PM
how can i turn functions written in VBA into an addin? avi Excel Programming 1 December 9th 04 03:04 PM
excel functions and User defined functions Kanan Excel Programming 4 May 20th 04 11:21 PM


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