1

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!

4
  • Where is your array coming from? Commented Apr 26, 2011 at 8:21
  • What do you mean Jonsca? Commented Apr 26, 2011 at 8:22
  • Is your array data on the same sheet? a different sheet? in a file? :) Commented Apr 26, 2011 at 8:23
  • ooh! it's on the same sheet :) Commented Apr 26, 2011 at 8:24

1 Answer 1

1

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)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.