User defined functions in vba ?

  • Thread starter Thread starter hglamy
  • Start date Start date
H

hglamy

Hello there,

is it possible to use udf in vba, and if so, how ?

Thank you in advance,

kind regards,

H.G. Lamy
 
Thank you, Harlan, I tried it, and it works.

However, now I notice that I should have put
the question slightly differently:

What I need is the use (in vba) of a function
that comes along in a protected excel add in.
I did not develop it, nor do I know the
mathematics behind it.

I can use that function inside a spreadsheet,
but how can I harness it in vba ?

Kind regards,

H.G. Lamy
 
hglamy said:
What I need is the use (in vba) of a function
that comes along in a protected excel add in.
I did not develop it, nor do I know the
mathematics behind it.

I can use that function inside a spreadsheet,
but how can I harness it in vba ?
....

..XLA add-in? If so, all you may need to do is add a reference to the XLA to
use its udfs in VBA in a different project. In the VB Editor, Tools >
References.

If all else fails, you could try using Evaluate. If this add-in provides a
function named fcn that takes a single argument, then

y = Evaluate("=fcn(" & CStr(x) & ")")

should return fcn(x) to y.
 
Harlan, thank you very much.

I seem to get closer to the solution.

Referencing in the vba-editor is done now.

What I can't find out is how to write the formula in the vba-editor.
Could you be of help once more ?

These are the details:

The addin is named "tma32.xla".
The function I refer to is this: =dbs4(Value, String, CellRef, CellRef,
CellRef, CellRef).

In which way or syntax do I have to put this inside a code module to make it
work ?
All my attempts and variations so far have failed.

Your assistance is greatly appreciated.

Thank you in advance,

Regards,

H.G. Lamy
 
hglamy said:
These are the details:

The addin is named "tma32.xla".
The function I refer to is this: =dbs4(Value, String, CellRef, CellRef,
CellRef, CellRef).

In which way or syntax do I have to put this inside a code module to make it
work ?
....

Dim y As Variant
y = dbs4(Rnd, "?", Range("A1"), Range("A2"), Range("B1"), Range("B2"))

Note: there may be ambiguity in these Range property calls. It's generally
best to qualify range references with the worksheet containing the range.
 
Back
Top