Juggler_IN
Active Member
- Joined
- Nov 19, 2014
- Messages
- 358
- Office Version
- 2003 or older
- Platform
- Windows
Hi,
I am getting a Type Mismatch Error in the following code:
I am not able to identify the cause. Help appreciated.
I am getting a Type Mismatch Error in the following code:
Code:
Sub z()
Dim u1 As Double, u2 As Double, m As Double, s As Double, i As Long
Dim z(1 To 2) As Double
m = 0
s = 1
For i = 1 To 100
u1 = Rnd()
u2 = Rnd()
z(1) = Sqr(-2 * Log(u2)) * Cos(2 * Application.WorksheetFunction.pi * u1)
z(2) = Sqr(-2 * Log(u2)) * Sin(2 * Application.WorksheetFunction.pi * u1)
Range("E" & i).Value = m + s * z
Next
End Sub
I am not able to identify the cause. Help appreciated.