开发者

Excel UDF returns a huge number

Excel AddIn using Excel DNA, VS2008, C#, MyUDF(param1, parm2) when I type in "=MyUDF" and hit enter, Excel displays a huge number like 970063926 and my c# code for MyUDF is not run

Anyone know what is this huge num开发者_运维技巧ber?

thanks


This is just a bit of weird behaviour of Excel. The number being returned is an internal identifier for the UDF function, and by entering the function name without any brackets, you're causing it to be treated like a named range not a function. If you want to call the function with no arguments, use:

=MyUDF()

...if you type =MyUDF then you're asking Excel to dereference the function name, in the same way that it would dereference =A1 to the value in cell A1 or =MyNamedRange to whatever that named range referred to.

I don't think there's any practical use for the behaviour you've observed, but it certainly isn't going anywhere near your code to get this value that is being returned, so don't worry you haven't done anything wrong!


Is there any way to avoid this behavior? If no parameter is specified, I would like the =MyUDF to return error instead a number.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜