Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
timspier
 
Posts: n/a
Default weird recalculation of user defined function


I created a small UDF which returns a value if the inputs are valid, but
if the inputs are not in the correct range it posts a messagebox with an
error message. If I copy this to a range of cells down a column, it
works great. If I insert a blank row somewhere in the range, no
problem. However, if I then DELETE the blank row, or any other row, all
the functions appear to be recalculated because I get a couple of error
messageboxes corresponding to the couple of inputs that are out of
range. I tried setting the volatile method to false, but no luck. Any
ideas what is going on?


--
timspier
------------------------------------------------------------------------
timspier's Profile: http://www.excelforum.com/member.php...o&userid=32090
View this thread: http://www.excelforum.com/showthread...hreadid=541840

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default weird recalculation of user defined function

timspier wrote...
I created a small UDF which returns a value if the inputs are valid, but
if the inputs are not in the correct range it posts a messagebox with an
error message. If I copy this to a range of cells down a column, it
works great. If I insert a blank row somewhere in the range, no
problem. However, if I then DELETE the blank row, or any other row, all
the functions appear to be recalculated because I get a couple of error
messageboxes corresponding to the couple of inputs that are out of
range. I tried setting the volatile method to false, but no luck. Any
ideas what is going on?


It's poor design to have udfs called from cell formulas display
dialogs. You're now seeing why. Much better for your udf to return an
error value, though something other than #VALUE! would be a good idea
because runtime errors in udfs return #VALUE! errors, then use
Calculate event handlers to check for cells containing these udfs and
evaluating to error values.

If your copied formulas had also had invalid values, they would also
have displayed dialogs when first pasted into cells. Also, if inserting
cells had lead to some of the udf calls having invalid values, that
would also have displayed dialogs. There's nothing special about
deleting cells, it's just that doing so caused some invalid values.

Anything that triggers recalc could affect the cell formulas calling
your udf and force its reevaluation. If the formulas calling your udf
also call other volatile functions, there's no way to prevent
reevaluating your udf except by setting calculation to manual.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips
 
Posts: n/a
Default weird recalculation of user defined function

Why not use Data Validation?

http://www.contextures.com/xlDataVal01.html

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"timspier" wrote in
message ...

I created a small UDF which returns a value if the inputs are valid, but
if the inputs are not in the correct range it posts a messagebox with an
error message. If I copy this to a range of cells down a column, it
works great. If I insert a blank row somewhere in the range, no
problem. However, if I then DELETE the blank row, or any other row, all
the functions appear to be recalculated because I get a couple of error
messageboxes corresponding to the couple of inputs that are out of
range. I tried setting the volatile method to false, but no luck. Any
ideas what is going on?


--
timspier
------------------------------------------------------------------------
timspier's Profile:

http://www.excelforum.com/member.php...o&userid=32090
View this thread: http://www.excelforum.com/showthread...hreadid=541840



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Harlan Grove
 
Posts: n/a
Default weird recalculation of user defined function

Bob Phillips wrote...
Why not use Data Validation?

....

Data validation doesn't work with formulas. It also doesn't work when
pasting into cells with data validation rules. Other than that it's
great.

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
Custom functions calculating time arguments Help Desperate Bill_De Excel Worksheet Functions 12 April 25th 06 02:22 AM
User defined charts Ajay Charts and Charting in Excel 0 January 17th 06 12:58 PM
User defined function linzhang426 New Users to Excel 4 October 10th 05 03:18 PM
Attaching a particular user defined function to cust button Ajay Excel Discussion (Misc queries) 3 February 23rd 05 08:29 AM
how to move user defined function Grant Excel Worksheet Functions 1 November 17th 04 06:38 PM


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