Hi everyone,
Good day to you all.
A couple days ago, a kind sir by the name Mike Rickson gave me a macro to extrapolate a set of random numbers from a given range of numbers from column A:1 all the way to A:49 sitting on 49 rows.
At the moment i am concerned for his wellbeing because he is not responding to my messages, hence i need to seek elsewhere for now.
The macro provided gave me a choice to extrapolate and fit the results into columns BCDE or more and a 100 rows or more for each of these columns. The code is pasted below.
Now i would like to work with these set of numbers instead, ranging from Column A:1_1 to A:49_49 sitting on 2401 rows in length.
E.g 1_1, 1_2, 2_4, 11_28, 31_45, all the way to 49_49... these gives us 2401 rows in length on column A.
Please look at the code and adjust as requested.
Sub test()
Dim Size As Long, inCount As Long
Dim numberChosen As Long
Dim RandIndex As Long
Dim rngData As Range, rngOut As Range
Dim inArray As Variant, outArray() As Long
Dim i As Long, j As Long
Set rngData = Range("A1").Resize(49, 1)
Set rngOut = Range("B1")
inArray = rngData.Columns(1).Value
inCount = UBound(inArray, 1)
numberChosen = Application.InputBox("how many to return", Default:=4, Type:=1)
If numberChosen < 1 Then Exit Sub: Rem cancel pressed
Size = Application.InputBox("how many to return", Default:=100, Type:=1)
If Size < 1 Then Exit Sub: Rem canceled
ReDim outArray(1 To Size, 1 To numberChosen)
For i = 1 To Size
For j = 1 To numberChosen
outArray(i, j) = inArray(WorksheetFunction.RandBetween(1, inCount), 1)
Next j
Next i
With rngOut.Resize(Size, numberChosen)
.EntireColumn.ClearContents
.Value = outArray
End With
End Sub
Thanking you in advance.
Good day to you all.
A couple days ago, a kind sir by the name Mike Rickson gave me a macro to extrapolate a set of random numbers from a given range of numbers from column A:1 all the way to A:49 sitting on 49 rows.
At the moment i am concerned for his wellbeing because he is not responding to my messages, hence i need to seek elsewhere for now.
The macro provided gave me a choice to extrapolate and fit the results into columns BCDE or more and a 100 rows or more for each of these columns. The code is pasted below.
Now i would like to work with these set of numbers instead, ranging from Column A:1_1 to A:49_49 sitting on 2401 rows in length.
E.g 1_1, 1_2, 2_4, 11_28, 31_45, all the way to 49_49... these gives us 2401 rows in length on column A.
Please look at the code and adjust as requested.
Sub test()
Dim Size As Long, inCount As Long
Dim numberChosen As Long
Dim RandIndex As Long
Dim rngData As Range, rngOut As Range
Dim inArray As Variant, outArray() As Long
Dim i As Long, j As Long
Set rngData = Range("A1").Resize(49, 1)
Set rngOut = Range("B1")
inArray = rngData.Columns(1).Value
inCount = UBound(inArray, 1)
numberChosen = Application.InputBox("how many to return", Default:=4, Type:=1)
If numberChosen < 1 Then Exit Sub: Rem cancel pressed
Size = Application.InputBox("how many to return", Default:=100, Type:=1)
If Size < 1 Then Exit Sub: Rem canceled
ReDim outArray(1 To Size, 1 To numberChosen)
For i = 1 To Size
For j = 1 To numberChosen
outArray(i, j) = inArray(WorksheetFunction.RandBetween(1, inCount), 1)
Next j
Next i
With rngOut.Resize(Size, numberChosen)
.EntireColumn.ClearContents
.Value = outArray
End With
End Sub
Thanking you in advance.