SerenityNetworks
Board Regular
- Joined
- Aug 13, 2009
- Messages
- 131
- Office Version
- 365
- Platform
- Windows
I'm trying to return the answer to the formula for BINOMDIST to the worksheet. However, unless I comment out the "cdf" row, the macro does not loop. I don't know what I'm doing wrong here. Any help will be appreciated.
Thanks,
Andrew
<tbody>
</tbody>
Thanks,
Andrew
Code:
Function AllowedErrors(Size As Double, Conf As Double, p As Double) As Long
Dim cdf As Double ' cumulative distribution function
Dim nSize As Double ' calculation counter
Dim nErrors As Double ' counter for errors
If Conf <= 0# Or Conf >= 1# Then Exit Function
If p <= 0# Or p >= 1# Then Exit Function
If nErrors = 0& Then nErrors = 1 ' sets initial value of nErrors to 1
With WorksheetFunction
Do
cdf = .BinomDist(nErrors, Conf, p, True)
Debug.Print (nErrors) & " | " & (Conf) & " | " & (p) & " | " & (cdf)
nErrors = nErrors + 1&
Loop While nErrors < Size + 1
End With
End Function
A | B | C | |
1 | Accuracy | 75.00% | |
2 | Confidence | 50.00% | |
3 | |||
4 | Allowed Errors | Sample Size | |
5 | 3 | A5: =AllowedErrors(B5, $B$2, 1-$B$1) | |
6 | 7 | A6: =AllowedErrors(B6, $B$2, 1-$B$1) | |
7 | 11 | A7: =AllowedErrors(B7, $B$2, 1-$B$1) | |
8 | 15 | A8: =AllowedErrors(B8, $B$2, 1-$B$1) |
<tbody>
</tbody>