LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default ReDim an array AFTER it's loaded into another array

Neal,
Without knowing the actual data structure you need I would guess something
like this:
private type RteFactsData
.RteName as string
.RteInfo1 as long
'.RteInfo2 as string 'etc depending on how many pieces of data you need
end type

Dim vRteFactsAy() as RteFactsData
'create the required number of elements somewhere
Redim vRteFactsAy(10)

'Then in your loop below, you can access the required data as
Cells(SheetRow, iDataType) = vRteFactsAy(iDataType).RteName
or
Cells(SheetRow, iDataType) = vRteFactsAy(iDataType).RteInfo1
depending on which piece of data "Index" refers to.

The benefit of this kind of code, is that it makes it more clear which piece
of data you are referring to. Compa
vRteFactsAy(iDataType).RteInfo1 to vRteFactsAy(iDataType)(Index)

NickHK

"Neal Zimm" wrote in message
...
Dear Nick,
I've looked at the Type constuct, and it's something I will use in my
app, but not for the question I posted. You could not know from my posting
('cuz I didn't state it as a requirement) how I use this data. I don't see
how I can put both the kind of data AND the route (which is what my app is
about) in a loop since the kind of data is in the .name structure. The

ReDim
requirement is nicely met however and I will use it in other places, so
thanks much for the heads up. See the code below for what I don't think is
possible with the user defined data contstruct.
Neal

RouteFacts.Org2ID = "District-811"


' this unloads the route facts array (the master in my posting) to a
worksheet.
RouteQty = 4
SheetRow = 1
For Index = 1 To RouteQty
' RFA is the route facts array
For iDataType = RFAOrg2IdCol To RFAnaPartCol
' RFAOrg2IdCol points to the "elem1" array in my posting

Cells(SheetRow, iDataType) = vRteFactsAy(iDataType)(Index)
Next iDataType
SheetRow = SheetRow + 1
Next Index

--
Neal Z


"NickHK" wrote:

Assuming the count in elem1 match the count elem2 (you'll always these 2
pieces of data together), why not use an array of custom types. e.g.

Public Type Data
Element1 as string
Element2 as long
End Type

Dim AllData() As data

redim AllData(1 to 10)

alldata(1).element1="Some value"
alldata(10).element2=5

redim preserve alldata(1 to 100)

NickHK

"Neal Zimm" wrote in message
...
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






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA syntax help: ReDim Preserve an array Dave Excel Discussion (Misc queries) 4 September 8th 07 07:37 PM
ReDim Array Viktor Ygdorff Excel Programming 2 July 10th 06 04:04 PM
ReDim Object array as parameter of Variant array Peter T Excel Programming 4 May 10th 05 02:11 PM
Dim / Redim of an Array Fred[_17_] Excel Programming 4 June 28th 04 03:16 PM
ReDim an Array Art[_5_] Excel Programming 3 October 25th 03 03:30 PM


All times are GMT +1. The time now is 07:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"