ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   help on UDF code (https://www.excelbanter.com/excel-discussion-misc-queries/111418-help-udf-code.html)

Dave F

help on UDF code
 
I have the following code to create a UDF to calculate reciprocals:

Function Reciprocal(a)
Reciprocal(a) = (1 / a)
End Function

The code is in a module.

I get #VALUE! errors when I try to run it. So I think this means that Excel
recognizes the UDF (otherwise it would return a #NAME error, right?)

So what's the problem here?

--
Brevity is the soul of wit.

Gary''s Student

help on UDF code
 
Avoid the appearance of recursion:

Function Reciprocal(a)
Reciprocal = (1 / a)
End Function


--
Gary''s Student


"Dave F" wrote:

I have the following code to create a UDF to calculate reciprocals:

Function Reciprocal(a)
Reciprocal(a) = (1 / a)
End Function

The code is in a module.

I get #VALUE! errors when I try to run it. So I think this means that Excel
recognizes the UDF (otherwise it would return a #NAME error, right?)

So what's the problem here?

--
Brevity is the soul of wit.


Dave F

help on UDF code
 
OK, that works, thanks.

What do you mean by the appearance of recursion?


--
Brevity is the soul of wit.


"Gary''s Student" wrote:

Avoid the appearance of recursion:

Function Reciprocal(a)
Reciprocal = (1 / a)
End Function


--
Gary''s Student


"Dave F" wrote:

I have the following code to create a UDF to calculate reciprocals:

Function Reciprocal(a)
Reciprocal(a) = (1 / a)
End Function

The code is in a module.

I get #VALUE! errors when I try to run it. So I think this means that Excel
recognizes the UDF (otherwise it would return a #NAME error, right?)

So what's the problem here?

--
Brevity is the soul of wit.


Gary''s Student

help on UDF code
 
There are some functions that are actually defined in term of themselves.
Factorials or Ackerman's function for example. See:


http://www.nist.gov/dads/HTML/ackermann.html
--
Gary's Student


"Dave F" wrote:

OK, that works, thanks.

What do you mean by the appearance of recursion?


--
Brevity is the soul of wit.


"Gary''s Student" wrote:

Avoid the appearance of recursion:

Function Reciprocal(a)
Reciprocal = (1 / a)
End Function


--
Gary''s Student


"Dave F" wrote:

I have the following code to create a UDF to calculate reciprocals:

Function Reciprocal(a)
Reciprocal(a) = (1 / a)
End Function

The code is in a module.

I get #VALUE! errors when I try to run it. So I think this means that Excel
recognizes the UDF (otherwise it would return a #NAME error, right?)

So what's the problem here?

--
Brevity is the soul of wit.



All times are GMT +1. The time now is 07:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com