Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default arrays in arrays

Hi,
Have a 2D array where each element contain a new 2D
array. Is it possible to perform a 'Redim Preserve' on an
array contained in the "mother" array? If so, what is the
proper syntax?

Any help appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default arrays in arrays

jacob wrote:

Hi,
Have a 2D array where each element contain a new 2D
array. Is it possible to perform a 'Redim Preserve' on an
array contained in the "mother" array? If so, what is the
proper syntax?

Any help appreciated.

The following seems to me kludgy, but the straightforward

ReDim Preserve motherArray(1,1)(3,5) wouldn't compile--syntax error

Sub abc()
Dim motherArray() As Variant
Dim containedArray() As Variant
Dim arrtemp() As Variant
Dim i As Long, j As Long
ReDim motherArray(1 To 2, 1 To 2)
containedArray = Range("A1:D3")
For i = 1 To 2: For j = 1 To 2
motherArray(i, j) = containedArray
Next: Next
arrtemp = motherArray(1, 1)
'Debug.Print UBound(motherArray(1, 1), 2) 'Check original UBound
ReDim Preserve arrtemp(3, 5)
motherArray(1, 1) = arrtemp
'Debug.Print UBound(motherArray(1, 1), 2) 'Checked changed UBound
'Debug.Print motherArray(1, 1)(3, 4) 'Check preservation
Erase arrtemp
End Sub

Alan Beban
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default arrays in arrays

I couldn't get this to work. Assuming you have something like:

Dim a, b, c, d, z
ReDim a(0 to 2)
ReDim b(0 to 2)
ReDim c(0 to 2)
ReDim d(0 to 2)

a(0) = b
a(1) = c
a(2) = d

The syntax would be somthing like

Redim Preserve a(1)(0 to 8)

but it gives a syntax error and won't compile.

I had to do something like this:

z = a(1)
Redim Preserve z(0 to 8)
a(1) = z


On Fri, 27 Aug 2004 06:35:23 -0700, "jacob"
wrote:

Hi,
Have a 2D array where each element contain a new 2D
array. Is it possible to perform a 'Redim Preserve' on an
array contained in the "mother" array? If so, what is the
proper syntax?

Any help appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default arrays in arrays

Thx for helping.
-----Original Message-----
I couldn't get this to work. Assuming you have something

like:

Dim a, b, c, d, z
ReDim a(0 to 2)
ReDim b(0 to 2)
ReDim c(0 to 2)
ReDim d(0 to 2)

a(0) = b
a(1) = c
a(2) = d

The syntax would be somthing like

Redim Preserve a(1)(0 to 8)

but it gives a syntax error and won't compile.

I had to do something like this:

z = a(1)
Redim Preserve z(0 to 8)
a(1) = z


On Fri, 27 Aug 2004 06:35:23 -0700, "jacob"
wrote:

Hi,
Have a 2D array where each element contain a new 2D
array. Is it possible to perform a 'Redim Preserve' on

an
array contained in the "mother" array? If so, what is

the
proper syntax?

Any help appreciated.


.

  #5   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default arrays in arrays

Thx for the effort.
-----Original Message-----
jacob wrote:

Hi,
Have a 2D array where each element contain a new 2D
array. Is it possible to perform a 'Redim Preserve' on

an
array contained in the "mother" array? If so, what is

the
proper syntax?

Any help appreciated.

The following seems to me kludgy, but the straightforward

ReDim Preserve motherArray(1,1)(3,5) wouldn't compile--

syntax error

Sub abc()
Dim motherArray() As Variant
Dim containedArray() As Variant
Dim arrtemp() As Variant
Dim i As Long, j As Long
ReDim motherArray(1 To 2, 1 To 2)
containedArray = Range("A1:D3")
For i = 1 To 2: For j = 1 To 2
motherArray(i, j) = containedArray
Next: Next
arrtemp = motherArray(1, 1)
'Debug.Print UBound(motherArray(1, 1), 2) 'Check

original UBound
ReDim Preserve arrtemp(3, 5)
motherArray(1, 1) = arrtemp
'Debug.Print UBound(motherArray(1, 1), 2) 'Checked

changed UBound
'Debug.Print motherArray(1, 1)(3, 4) 'Check

preservation
Erase arrtemp
End Sub

Alan Beban
.

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
Two arrays same? FARAZ QURESHI Excel Discussion (Misc queries) 4 April 23rd 09 12:22 AM
Arrays Brendan Vassallo Excel Discussion (Misc queries) 4 February 23rd 06 02:27 AM
Arrays JAmes L Excel Programming 3 April 21st 04 11:00 AM
Arrays Aaron Cooper Excel Programming 2 April 14th 04 07:42 PM
help with arrays mike Excel Programming 4 February 13th 04 01:43 AM


All times are GMT +1. The time now is 01:04 PM.

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

About Us

"It's about Microsoft Excel"