I am having trouble with the following code to get repeated series of random numbers using a seed value. The series obtained are always different.
Option Base 1
Option Explicit
Function MyRnd(n, Optional seed)
Dim x() As Double
ReDim x
' Dim xc As Integer
' Dim xp As Double
Dim i As Integer
' Dim s As Double
If IsMissing(seed) Then
For i = 1 To n
x(i) = Rnd
Next i
Else
Randomize seed
For i = 1 To n
x(i) = Rnd
Next i
End If
MyRnd = WorksheetFunction.Transpose(x)
End Function
Option Base 1
Option Explicit
Function MyRnd(n, Optional seed)
Dim x() As Double
ReDim x
' Dim xc As Integer
' Dim xp As Double
Dim i As Integer
' Dim s As Double
If IsMissing(seed) Then
For i = 1 To n
x(i) = Rnd
Next i
Else
Randomize seed
For i = 1 To n
x(i) = Rnd
Next i
End If
MyRnd = WorksheetFunction.Transpose(x)
End Function