Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You need to get the upper bound of the second dimension, not the first:
For x = 0 To UBound(arrCAT_NAM, 2) Debug.Print "#: " & arrCAT_NAM(0, x) Debug.Print "Descr: " & arrCAT_NAM(1, x) Next x Regards, Steve TroyH.PHS schrieb: Thanks for the quick reply. I appreciate the help but I think I may have goofed in my initial design. But I do appreciate the info and it has helped clear some light on my mistake. Let me try again. I need to build an array as the info comes about. I do not have all the data at the beginning. I need help with using the REDIM statement and how to pull the data from a multi-dimension array. I now know that my inital idea for an array went: # Item Desc. 4 DESC1 5 DESC2 6 DESC3 7 DESC4 8 DESC5 9 DESC6 ... <--- New row added when data was found coded as: ReDim Preserve arrCAT_NAM(COUNT, 1) arrCAT_NAM(arrCOUNT, 0) = # arrCAT_NAM(arrCOUNT, 1) = DESC COUNT = COUNT + 1 I learned that I was wrong, it has to be: 4 5 6 7 8 9 DESC1 DESC2 DESC3 DESC4 DESC5 DESC6 coded as: ReDim Preserve arrCAT_NAM(1, COUNT) arrCAT_NAM(0, arrCOUNT) = # arrCAT_NAM(1, arrCOUNT) = DESC COUNT = COUNT + 1 So my questions is, how do I pull the data out. I tried... For x = 0 To UBound(arrCAT_NAM, 1) MsgBox arrCAT_NAM(x, 0) Next x but it does not work. Thanks. " wrote: Part A: Dim textArr(noOfFiles -1, maxNoOfItems) Dim i As Integer, j As Integer i = 0 j = 0 For i To noOfFiles textArr(noOfFiles, 0) = getDescr() 'first item of second dimension is always description For j To noOfItems textArr(noOfFiles, j +1) = getItem() Next j Next i Part B: You would populate the first ListBox with your textArr like so: Dim i As Integer For i = 0 To UBound(textArr, 1) lstBox1.add textArr(i, 0) Next i And in your second ListBox's change event, you want something like this: Dim indx As Integer indx = lstBox1.ListIndex If indx = 0 Then Dim i As Integer i = 1 while (i <= UBound(textArr, 2) And (textArr(indx, i) < "") lstBox2.add textArr(indx, i) i = i + 1 wend Else lstBox2.clear End If Regards, Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multidimensional array - lookup | Excel Programming | |||
Syntax for multidimensional array | Excel Programming | |||
Sort MultiDimensional Array | Excel Programming | |||
Multidimensional Array | Excel Programming | |||
MAX of Multidimensional Array | Excel Programming |