Problems with LN in VBA

N

NooK

I am trying to create this function

Function CalcWeibX(N As Double, B As Double, Fx As Double) As Double
Dim Power As Double
Power = 1 / B
CalcWeibX = -N * ((Application.WorksheetFunction.Ln(1 - Fx))
(Power))

End Function

But all I keep getting is a "Invalid Procedure Call or Argument".

VBA won't allow me to have a Real number on both LN argument an
Power.

If I run LN(0.5)^2, it works

If I run LN(2)^(0.5), it works

But If I have real numbers on both arguments (Ex: LN(0.5)^0.2), I ge
the error. Am I doing something wrong here, I think it should work.

I've tried both Excel LN function and VBAs Log function and both giv
same error and I get something about not finding Excel Power functio
if I try to use

Application.WorksheetFunction.Power instead of the ^.

Best Regards

Noo
 
D

Dana DeLouis

But If I have real numbers on both arguments (Ex: LN(0.5)^0.2), I get
the error. Am I doing something wrong here, I think it should work.

If I am not mistaken, a Negative number (Log(.5)) raised to .2 is a "Complex
Number."

You can probably see it a little better with...

=IMPOWER(LN(0.5),0.2)

Function CalcWeibX(N As Double, B As Double, Fx As Double) As Double
CalcWeibX = -N * (Log(1 - Fx) ^ (1 / B))
End Function

HTH
Dana DeLouis
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top