简体   繁体   中英

VBA worksheetfunction gamma_dist using in cycle for..next

My cycle:

For n = 1 To 30000 Step 1
    a = m * n
    b = delta ^ a
    c = f1 ^ (a - 1)
    d = WorksheetFunction.Exp(-f1 * delta)
    e = WorksheetFunction.Gamma_Dist(f1, a, 1, 1)
    konvolucia = (b / e) * c * d
Next n

over the e is displaying

runtime error.'423' - Property or method not found

Can I ask you where the problem is?

As the error message

Property or method not found

tells you, the issue is there is no WorksheetFunction called Exp .

If you are looking for the exp function defined as:
Exp(n) = e raised to the n th power, where e = 2.71828183… .

Then use d = Exp(-f1 * delta) instead.


Side note
Gamma_Dist awaits a Boolean as last argument:

Gamma_Dist(Arg1 as Double, Arg2 as Double, Arg3 as Double, Arg4 as Boolean)

So you should use True or False instead of 1 as last argument. In VBA True is -1 and False is 0 so don't use 1 even if anything beside 0 casts to True when converted to Boolean.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM