Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Mark date that has passed | Excel Worksheet Functions | |||
how do I fix a forecast date that has passed for a zero value? | Excel Discussion (Misc queries) | |||
IF Formula to calculate whether date has passed | Excel Discussion (Misc queries) | |||
Date Passed Notification | Excel Discussion (Misc queries) | |||
how do i work out how many hrs have passed in a 24 hr clock, in ex | Excel Worksheet Functions |