I have a list of names in column A on sheet 1.
Upon running a sub, those names are placed into an array, shuffled into a random order and then put back into sheet 1 column a in their new order.
What I now want to do is evenly split the array values by a number that the user enters via an input box and for these to be placed in their own array.
i.e. If I have a have a list of 100 names and the user enters 4 after being prompted, 4 different arrays would be created with 25 elements in each.
Similarly, if the user inputs 5 then 5 different arrays are created with 20 elements in each.
I do not mind in terms of naming conventions for the arrays. I guess something like arr1, arr2, etc would be easiest but I just can't figure out how to do this!
Any help would greatly be appreciated.
Here is my code so far:
Option Explicit
Option Base 0
Sub test_Macro()
Dim nTM As Long, N As Long, J As Long, i As Long
Dim arr() As Variant, Temp As Variant
arr = Sheets("Sheet1").Range("A2:A" & Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row).Value 'set array range
'****** randomly sort array
Randomize
For N = LBound(arr) To UBound(arr)
J = CLng(((UBound(arr) - N) * Rnd) + N)
If N <> J Then
Temp = arr(N, 1)
arr(N, 1) = arr(J, 1)
arr(J, 1) = Temp
End If
Next N
'******* put randomly sorted array back on worksheet
For i = LBound(arr) To UBound(arr)
Sheets("Sheet1").Cells(i + 1, "A") = arr(i, 1)
Next i
End Sub
Bookmarks