Sub Button8_Click()
Dim count, vari, counter, Rep_Counter, Zero_Counter, reps, patients As Integer
Dim CountAccept As Integer
Dim n, r, p As Single
Dim sd, zero_fraction As Double
n = Cells(1, 2)
r = Cells(2, 2)
p = Cells(3, 2)
'Generates random numbers
For reps = 1 To r
count = 0
For patients = 1 To n
Do
vari = "=rand()"
If vari < p Then Set count = count + 1
Loop While counter < n
Next patients
If count = 0 Then Set Zero_count = Zero_count + 1
Next reps
zero_fraction = Zero_count / reps
sd = Sqr(((zero_fraction) * (1 - zero_fraction) / reps))
'MsgBox ("Probability no one accepts organ is " & Range("A10") & " and " & Range("A12"))
Cells(3, 3) = zero_fraction
End Sub
Bookmarks