ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problems with LN in VBA (https://www.excelbanter.com/excel-programming/303117-problems-ln-vba.html)

NooK[_34_]

Problems with LN in VBA
 
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

--
Message posted from http://www.ExcelForum.com


Dana DeLouis[_3_]

Problems with LN in VBA
 
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


"NooK " wrote in message
...
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 and
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 get
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 give
same error and I get something about not finding Excel Power function
if I try to use

Application.WorksheetFunction.Power instead of the ^.

Best Regards

NooK


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 05:50 PM.

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