LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Changing values of an array of arrays

I am attempting to use an array of arrays (ragged arrays), but am having
problems.

It seems the master-array elements must set equal to the sub-arrays only
AFTER the values are entered for the sub-arrays. Then it seems the values of
the elements are set and cannot be changed. Here is my sample
code with comments (my next question follows);

'==================
Sub ABC()
Dim vArr1(1 To 10) As Variant
Dim vArr2(1 To 5) As Variant
Dim vMainArr(1 To 2) As Variant
Dim lCounter As Long
Dim s As String, i As Long, j As Long

' Populate the sub arrays:
For lCounter = 1 To 10
vArr1(lCounter) = lCounter
If lCounter < 6 Then _
vArr2(lCounter) = lCounter * 2
Next lCounter

' Assign the sub arrays to the main array:
' Note that if this isn't done after are populated with values, the array
will be empty.
vMainArr(1) = vArr1
vMainArr(2) = vArr2

'change one of the elements as a test
vArr2(2) = 100 ' note that this change WON'T show in the vMainArr array

' Show the results
s = ""
For i = 1 To 2
For j = LBound(vMainArr(i), 1) To UBound(vMainArr(i), 1)
s = s & vMainArr(i)(j) & ","
Next j
s = s & vbNewLine
Next i
MsgBox s

End Sub

'==================

If my issues above are true, then I need to figure out a way around these
limitations. Note that my actual program would have perhaps 200 elements in
the main array, and 20 sub elements.of mixed type (strings and numbers), then
about 5 of the sub-sub elements would be 1-dimensional arrays. Just using 200
separate arrays would not be desirable.

Perhaps I must repeat the lines where sub arrays are assigned to the main
array EVERY time I change a value.

Any other suggestions?

Joe Dunfee
 
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
RENEWED-- Arrays: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 5 April 20th 07 01:30 AM
Changing values in an array using for each Andrew Hall NZ Excel Programming 2 March 19th 07 12:50 AM
Using known arrays to calculate an array of new values Brett[_9_] Excel Programming 8 September 19th 06 06:32 AM
Arrays - declaration, adding values to arrays and calculation Maxi[_2_] Excel Programming 1 August 17th 06 04:13 PM
Array of Arrays in VBA Peter[_49_] Excel Programming 0 November 9th 04 09:50 PM


All times are GMT +1. The time now is 05:04 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"