Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 51
Default Create and Update Multidimensional Array

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
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
Multidimensional array - lookup Jason Morin Excel Programming 5 September 27th 06 06:49 PM
Syntax for multidimensional array Arne Hegefors Excel Programming 1 August 22nd 06 06:19 PM
Sort MultiDimensional Array Mushi Excel Programming 1 August 2nd 06 05:34 AM
Multidimensional Array DavidMoeller Excel Programming 4 August 12th 04 08:12 PM
MAX of Multidimensional Array ZZZ Excel Programming 2 November 15th 03 03:32 PM


All times are GMT +1. The time now is 06:43 AM.

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"