Ok, so I cannot figure out how to get this to output only 25% of my original list. This list is dynamic and will change. I just want to be clear I want to randomly select 25% of this list and copy it to another tab. Any help would be appreciated.
Sub RandomPull()
Dim q2 As Integer
Dim ws As Worksheet
Dim Keyl As Range
Dim Rowi As Integer
Dim NumOfK As Integer
Set ws = Worksheets("Key List")
Set Keyl = ws.Range("Table5[Key]")
Rowi = Keyl.Rows.Count
q2 = 25
NumOfK = Round(q2 / 100 * Rowi)
Dim myNames As Variant
Dim Temp As String
Dim i As Integer
Dim rIndex As Integer
Dim outRRay(1 To 25, 1 To 4) As String
myNames = Application.Transpose(Range("Table5[Key]").Value)
randomize
For i = 1 To Rowi
rIndex = Int(1 + (Rnd() * NumOfK))
Temp = myNames(i)
myNames(i) = myNames(rIndex)
myNames(rIndex) = Temp
Next i
For rIndex = 1 To 25
For i = 0 To 3
outRRay(rIndex, i + 1) = myNames((25 * i) + rIndex)
Next i
Next rIndex
Worksheets("Random List").Range("a:a").Value = outRRay
End Sub
Bookmarks