ReDim an array AFTER it's loaded into another array
Jim -
Yes, in the macro where the master is created that is indeed what I do.
what I neglected to put into the original post was that the master is passed
from macro to macro. ( it's a small data base containing facts gleaned from
some of the worksheets in the workbook that's at the hub of my application)
Once outside the macro where the master was created, the 'elemental'
arrays are gone and can't be "addressed". The master is my shorthand way of
accessing a lot of data without dragging around all of the elemental arrays.
(There are 12 of them in actuality) I may have to go back my original design
which was one two-dimension array, so I can redim a column to add what I
need. I'll be tryout out Tom's answer tonight. Soon.
Thanks for your reply.
--
Neal Z
"Jim Thomlinson" wrote:
I like Tom's code but if you want to stick with you roriginal line of thought
then this might help...
Sub test()
Dim master(2)
Dim elem1() As String
ReDim elem1(3)
Dim elem2() As Integer
ReDim elem2(3)
master(1) = elem1
master(2) = elem2
ReDim Preserve elem1(4)
master(1) = elem1
End Sub
--
HTH...
Jim Thomlinson
"Neal Zimm" wrote:
HI All,
I have an array whose elements are other arrays. I use option base 1, and
things are OK.
Once a "master" array is formed, it looks like the component arrays cannot
be re-dimmed.
The ReDim VBA help is silent on this ability.
in a procedu
dim master(2)
dim elem1() as string
redim elem1(3)
dim elem2() as integer
redim elem2(3)
values are put into elem1 and elem2 and then:
master(1) = elem1
master(2) = elem2
I was testing trying to ReDim " elem1" and "elem 2" AFTER the
master was "loaded".
I get an immediate compiler 'red ink' error when I type:
Redim master(1)(4)
Note: ReDim master(3) to add another array does me no good.
I guess I have to leave "room" in elem1 and elem2 before they
are loaded into the master, or unload the master to the
elemental arrays, ReDim them, and finally re-load back
to the master.
Am I correct, or is there another way?
Thanks,
--
Neal Z
|