Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Bill Howell   on Sep 20 In MS Office Category.

  
Question Answered By: Nahal Malik   on Sep 20

Can't actually tell what you want to know. Please ask a more specific
question. And show your code and any error messages.

Function parameters  can be (and often are) of many different data  types.
What you have in your parameter string  looks legal, although I do prefer to
see "ByRef" or "ByVal" for each parameter.

What is missing is a definition of the return  type of the function. This
means that the return type  will be whatever type you assign to the function
name inside the function. This can give  a run-time error if the return
value is assigned to a variable of an incompatible type. Give the function
a return type, and the compiler can check compatibility for you at compile
time.


BTW your second parameter is currency, not double. I haven't looked at how
VBA stores currency  variables, but it's certainly not the same as doubles -
more precision and less decimal places. I don't know whether this could be
causing your problems

> We all know that UDF errors  are hard  to debug  ...

UDF (I assume you mean "User Data Form" - actually just called User Form in
Excel) errors are very easy to debug in Excel, due to the availability of
break-points, code stepping, an immediates window, and a watch window. Plus
the fact that an uncaught error offers a "debug" option to allow you to go
straight to the line that's causing the problem  - and, in many cases, simply
to fix it and re-execute it.

Share: 

 

This Question has 3 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Different Parameters in Excel UDF Or get search suggestion and latest updates.


Tagged: