Reputation: 10113
How do you read the data from a dynamic array out?
ReDim idx(1 To nItemsToPick)
ReDim varRandomItems(1 To nItemsToPick)
For i = 1 To nItemsToPick
Do
booIndexIsUnique = True
idx(i) = Int(nItemsTotal * Rnd + 1)
For j = 1 To i - 1
If idx(i) = idx(j) Then
booIndexIsUnique = False
Exit For
End If
Next j
If booIndexIsUnique = True Then
Exit Do
End If
Loop
varRandomItems(i) = rngList.Cells(idx(i), 1)
Next i
Thank you!
Upvotes: 1
Views: 1116
Reputation: 10381
Somehow you have to get the user to input a starting cell and whether they want the data horizontally or vertically.
Then if the user inputs "A1", and there are 10 elements and the orientation is horizontal you need to turn that into a string -> "A1:A10"
Range("A1:J10") = varRandomItems
or
Range("A1:A10") = Application.Transpose(varRandomItems)
(apologies, I'm forgetting how to put the strings together at this point)
Upvotes: 1