I am building a macro and one of the formulas in the function is a customfunction I built.
I am getting an error.
Here's a piece of the code.
Lambda = LossCurves.Cells(X, 1)
Theta = LossCurves.Cells(X, 6)
Maximum = LossCurves.Cells(X, 5)
Freqrnd = Rnd
Freq = PoissonInv(FreqRnd,Lambda)
The PoissonInv function is defined in my library:
Public Function PoissonInv(CDF, meanX)
If CDF < 0 Or CDF >= 1 Then PoissonInv = "The curve must be evaluated between 0 and 1": Exit Function
X = 0
p = Exp(-meanX)
tp = p
Do While CDF > tp
X = X + 1
p = p * meanX / X
tp = tp + p
Loop
PoissonInv = X
End Function
I am getting an error.
Here's a piece of the code.
Lambda = LossCurves.Cells(X, 1)
Theta = LossCurves.Cells(X, 6)
Maximum = LossCurves.Cells(X, 5)
Freqrnd = Rnd
Freq = PoissonInv(FreqRnd,Lambda)
The PoissonInv function is defined in my library:
Public Function PoissonInv(CDF, meanX)
If CDF < 0 Or CDF >= 1 Then PoissonInv = "The curve must be evaluated between 0 and 1": Exit Function
X = 0
p = Exp(-meanX)
tp = p
Do While CDF > tp
X = X + 1
p = p * meanX / X
tp = tp + p
Loop
PoissonInv = X
End Function