LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 968
Default Passed Arguments to a UDF

I don't think this is a bug.
Sounds to me like F14 has not yet been calculated and is therefore Empty
when the function FBank is first called. Converting Empty to Integer gives
zero. The function will eventually be called again when F14 is recalculated.

This can easily happen if the initial calculation chain is out-of-sequence:
I recommend checking all UDF input parameters for this condition.
see http://www.DecisionModels.com/Calcsecretsj.htm for more details.

Charles
__________________________________________________
The Excel Calculation Site
http://www.decisionmodels.com

I recommend
"Bob Myers" wrote in message
...
Ron, using your function, I get your results -- which led to further
investigation.

Function FBank(ub As Integer, rRange As Range)
FBank = ub
End Function


What I found was that when I put a break point inside the function is when
the ub value doesn't get passed. Was having a lot of trouble with the
function's algorithm and every time I stopped the function in the
debugger, the value of ub was 0. This led me to believe ub was why my
algorithm wasn't working (wasted a lot of time). For some reason, the
argument in the form of INT(F14) allowed me to see the value of ub in the
debugger. After the algorithm was correct, and with your help, I removed
the INT() from the call, and still get the correct results.

I would guess it is an anomaly in the debugger.

Thanks again.

R/Bob


"Ron Rosenfeld" wrote in message
...
On Sat, 22 Nov 2008 14:38:56 -0500, "Bob Myers" wrote:

Ron, this is going to get messy -- but you asked, and thanks.

My previous rendition was simplified. The following accurately reflects
the
actual.

F14 holds:
'=IF(OR(nBank=0,A14="S"),"",COUNTIF(G14:OFFSET( F14,0,iWk3),"=x"))'
Where nBank is set on another tab and is 12, and iWk3 is set on this tab
and
is 18.
It returns the number of x's in the first 18 Cells of Range G14:AO14,
which is 2.

G14:AO14 holds:
'|*|22|20|x|22|20|*|19|20|*|18|17|x|19|20|*|23| 24|*|25|21|*|20|21|x|18|17|*|*|*|*|*|*|'
Where * = Null (empty, blank)

AQ14 holds: '=FBank(F14, G14:AO14)'

UDF header: 'Function FBank(ub As Integer, rRange As Range)'

With F14 in the function call, ub is always 0, which includes 'ByVal ub
As
Integer.'
I've also tried 'ub As Variant,' and still ub = 0.
If I set D14 to '=F14' and change FBank's call to FBank(D14, G14:AO14),
ub =
0;
but if I set D14 to 2, ub will be 2.
If I change FBank's call to FBank(F14:AO14) and read the first cell, it
will
be 0.
If I change FBank's call to FBank(ROW(), G14:AO14), the row comes thru as
14;
but 'ub = Range("F14")' still comes out as 0; as does
Range("Sheet!F14").
If I change the FBank call to FBank(2, G14:AO14), ub will be 2.

I've tried as many work-arounds as I can think of to get the value of F14
into my UDF.
Although it would be nice to know why I can't, I'd be be semi-happy just
to
get it there.


Using your information to reproduce what you have done, I have no problem
with
the values you have used.


Again, how are you determining that ub is not being properly passed?

Since you did not indicate that, I used a very simple UDF:

Function FBank(ub As Integer, rRange As Range)
FBank = ub
End Function


As expected, the function returned a value of 2.
--ron






 
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
Mark date that has passed Michaela Excel Worksheet Functions 5 September 22nd 08 02:31 PM
how do I fix a forecast date that has passed for a zero value? chicken Excel Discussion (Misc queries) 0 November 29th 06 06:05 AM
IF Formula to calculate whether date has passed Janelle Lister Excel Discussion (Misc queries) 4 October 19th 06 03:32 PM
Date Passed Notification Lori Excel Discussion (Misc queries) 3 April 12th 06 05:46 PM
how do i work out how many hrs have passed in a 24 hr clock, in ex excelious Excel Worksheet Functions 2 March 10th 05 11:51 AM


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