I am not so great at VBA and have been trying to do something very simple" replace this GOTO for some kind of conditional loop, but for some reason I keep getting error messages.
I know this is simple to some of you here!
VBA Code:
Function gauss()
Dim fac As Double, R As Double, V1 As Double, V2 As Double
10 V1 = 2 * Rnd - 1
V2 = 2 * Rnd - 1
R = V1 ^ 2 + V2 ^ 2
If (R >= 1) Then GoTo 10
fac = Sqr(-2 * Log(R) / R)
gauss = V2 * fac
End Function
I know this is simple to some of you here!