Thread: Alter existing code to include new functions

1. Alter existing code to include new functions

Code "GenerateRandom" generates random numbers.
Is there a way of selecting the numbers from a range of date sets to generate random numbers onto another sheet?

I have attached a workbook with the code.

If so I would appreciate some help.

Code:
```Option Explicit
Option Base 1
Public jj As Long
Public Const iteration = 100

'***********************************************************************
'*                                     Generate Sampling Process                                       *
'***********************************************************************

Sub GenerateRandom()
Dim i As Long
Dim hold(100) As Single, Hold2(100) As Single
Randomize

For i = 1 To 100
Hold2(i) = i
Next i

For jj = 1 To iteration

For i = 1 To 100
hold(i) = Rnd
Next i

Call DoubleSort(100, hold, Hold2)

For i = 1 To 14
Cells(jj + 3, i) = Hold2(i)
Next i

Next jj

End Sub

'***********************************************************************
'*             Sorting Process -  Sort array y based on array x                 *
'***********************************************************************

Sub DoubleSort(n As Long, x() As Single, y() As Single)
Dim xTemp As Double
Dim yTemp As Double
Dim i As Long
Dim j As Long

For j = 2 To n

xTemp = x(j)
yTemp = y(j)

For i = j - 1 To 1 Step -1
If (x(i) <= xTemp) Then GoTo 10
x(i + 1) = x(i)
y(i + 1) = y(i)
Next i

i = 0
10   x(i + 1) = xTemp
y(i + 1) = yTemp

Next j

End Sub```

2. Originally Posted by johnmason
I have attached a workbook with the code.
No you haven't.
The code isn't enough - we need to know more about the 'range of date' sets and the kind of 'numbers' you want on which sheet.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•