Randomly select datarows

I have a dataset that contains 95 records. I need to randomly take the 95 records and put into 5 groups of 19.

Is there a quick and easy way to do this without pulling teeth or just pulling records from a hat

Thanks for the information.



Answer this question

Randomly select datarows

  • Greg Neilson

    Thanks for the help. This is exactly what I needed.
  • CallumP

    I wrote a code to do what you are looking for, store the records in TheMainArray, then you will find it dispensed randomly in the five arrays (PArray)...
            Dim TheMainArray(94) As String
           'Store the records in "TheMainArray"
            Dim PArray(4) As ArrayList
            Dim TempRandom As New Random
            Dim TempIndex As Integer
            For TempIndex = 0 To 94
                Dim Index As Integer
                Index = TempRandom.Next(0, 5)
                If PArray(Index).Count < 15 Then
                    PArray(Index).Insert(TempRandom.Next(0, 15), (TheMainArray(TempIndex)))
                Else
                    TempIndex -= 1
                End If
            Next



  • Randomly select datarows