Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multipule arrays not functioning 2

Status
Not open for further replies.

Pimafix

Technical User
Sep 6, 2006
14
US
Could anyone give me a hand trying to figure this out.
I am trying to collect array data (dynamic array) and am running an array to collect the numbers, a second array to collect the names assocaited with the numbers and then have to run a third array to collect the file label associated with the number. The arrays will collect and the numbers of each array are identical but the problem is three fold -
First, I can't get the arrays to keep going. This is how I collect the array data for each array except that the name of the array changes.

Num = 0
Range("A1").Select

Do
ReDim Preserve NameArray(Num)
If IsEmpty(ActiveCell) Then
Exit Do
End If
NameArray(Num) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Num = Num + 1
Loop

Range("B1").Select
Num = 0

Do
ReDim Preserve NumberArray(Num)
If IsEmpty(ActiveCell) Then
Exit Do
End If
NumberArray(Num) = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
Num = Num + 1
Loop

This works great but would a two dimensional array work better?

Second, I want to collect the names and numbers of the data but also have several file numbers to associate with each of the names collected (its for a report).

These arrays are to collect file data. So for sake of example - a manager is listed, the managers floor is listed and under each manager comes each employee on the floor.
Is this three simple arrays, a two dimensional array with a seperate array for each managers name showing employees, or is it a three dimensional array?

Any ideas?
 



Hi,

Consider ONE loop
Code:
dim arry(2,1)
lLastRow = activesheet.cells(activesheet.cells.rows.count, 1).end(xlup).row
redim arry(2,lLastRow-1)
for lRow = 1 to lLastRow
  for iCol = 1 to 3
    arry(icol-1, irow-1) = activesheet.cells(lrow, icol).value
  next
next


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Arrays can only contain a single data TYPE (text/string; currency; single; integer; ...) so the multiple dimension is probably not that useful.

A UDT, can include different data types, and you can have an ARRAY of the UDT type - which looks like a better path (to me) as long as the values in the arrays are actually related.

See User Defind Types in Help




MichaelRed


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top