Quote Originally Posted by swambast View Post
How do I take the UBound() elements from an existing array, and use it to populate a brand new array?
I've read that sentence about five times, and can't figure out its intent. I read the example about three times, and it didn't help.

The best I can figure out is that you're trying to copy one array to another array. If that's the case, just use dynamic arrays and then you can do simple array assignment:

Code:

Option Explicit

Private Sub Form_Load()
    Dim a1() As String
    Dim a2() As String


    ReDim a1(0 To 3)
    a1(0) = "asdf"
    a1(1) = "qwer"
    a1(2) = "zxcv"
    a1(3) = "poiu"

    a2 = a1                                 ' Copies the entire array.

    Debug.Print a2(0), a2(1), a2(2), a2(3)  ' Output is: asdf  qwer  zxcv  poiu


End Sub


Are you possibly trying to take some subset of elements out of array #1 and place them into array #2? If that's the case, the most obvious way is to use a loop. However, depending on the array type (non reference, i.e., non-string, non-object) then you could speed things up with some smart use of CopyMemory. However, you suggested an array of strings. If that's the case, and you're trying to create some subset in a new array, I'd recommend a loop. Using CopyMemory in that case, you'd have to take care of how you erased your new array, as you'd be aliasing strings which is always dangerous.

However, I still fear that I don't understand what you're trying to do.