Help in Excel VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to know if there is a simple way to fill an array variable with several independent arrays.
I.E. I have 12 variable arrays and I need to concatenate it into one.

Is that possible?

Thank you very much.

Regards,

João Lagarto
 
You cannot say Array1 = Array2 + Array3. Rather, you'd have to build Array1
from the elements of the existing arrays. Each vector of Array1 would have
to be as large as the largest equivalent vector of the source arrays. For
example, if Array2 is 3 by 1 and Array3 is 1 by 4 then Array1 would have to
be 3 by 4. That is, if I'm following you.
 
Not quite...
just want to build an array picking all separated array's.
in my situation i have (for instance):
v1(2 by 8)
v2(2 by 11)
v3(2 by 4)
v4(2 by 6)
.....
v_all(2 by ??)

as ?? would be 8+11+4+6+...

I can do it with For cylces, but I wandered if there were a simple way of doing it like
v_all() = v1() & v2() & v3() & etc...

Hope to explained it better, if not, thank you any way for your time.

Regards,

João Lagarto
 
Joao,

Try something like

Dim Arr1(2, 8)
Dim Arr2(2, 11)
Dim Arr3(2, 4)
Dim Arr4(2, 6)
Dim Arr_All()
Dim Lim As Long

Lim = UBound(Arr1, 2) + UBound(Arr2, 2) + UBound(Arr3, 2) +
UBound(Arr4, 2)
ReDim Arr_All(2, Lim)



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



message
news:[email protected]...
 
Dim CArray() As Varian
redim carray (ubound (ARRAY1())+ubound(array2())+ ubound(array3())+...-12
For c1 = 0 To UBound(array1()) -
CArray(c1) = array1(c1
Next c
For c2 = c1 + 1 To c1 + UBound(array2()
caray(c2) = array2(c2 - (c1 + 1)
Next c
For c3 = c2 + 1 To c2 + UBound(array3()
CArray(c3) = array3(c3 - (c2 + 1)
Next c
...
 
Back
Top