Thread: UDF
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default UDF

Assuming your UDF is something like:
Public Function AddMe(arg1 As Double, arg2 As Double, arg3 As Double) As
Double
AddMe = arg1 + arg2 + arg3
End Function

And you are calling it from a cell with:
=addme(D18,15.45,RAND()*10)

It will work.

Of course your VBA code has be valid and return the correct answer/data
type.
It would be better to type your arguments and return value to avoid working
with Variants. See the example below, assuming your UDF code, in A1:C2.

=duration(B1,C1) One Word
=duration(B2,C2) 1 2

Which is correct ?

NickHK

"Arne Hegefors" wrote in message
...
Hi! I am trying to write a simple udf that takes three parameters as
argument. never mind what the udf is supposed to do, i just cant get it to
work for more than one argument. pls help me!

Function duration(n, t)
duration = n + t
End Function

This works for one argument (i then skip the t in the duartion line). pls
help!