Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim Arr as variant
arr = array(5,6,10) DSH wrote: Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to dynamically set the number of dimensions and elements, not the
values of the elements. The dimensions and elements are dynamic, i.e. they change. So I need a way programmatically to easily change these. arr() may be arr(5, 6, 10) or arr(1, 2, 9, 4), etc. etc. "Dave Peterson" wrote: Dim Arr as variant arr = array(5,6,10) DSH wrote: Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. -- Dave Peterson . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is this what you are wanting? Hope this helps! If so, let me know, click
"YES" below. dim arr() dim s as string s = "5, 6, 10" arr = Split(s, ",") -- Cheers, Ryan "DSH" wrote: Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No, sorry. I didn't state my original question well. I need an easy way to
change the number of dimensions of an array based on the changing value of the number of dimensions and elements. Here's the long way to do it: numberOfdimensions = n d(0) = 5 d(1) = 6 d(2) = 10 select case numberOfdimensions: case 1: redim arr(d(0)) case 2: redim arr(d(0), d(1)) case 3: redim arr(d(0), d(1), d(2)) etc. etc end select *** I'm looking for a simpler way. The following won't work, but is there a similar way to do this: for ddx = 0 to 2 s = s & d(ddx) & ", " ' s will end up = "5, 6, 10" next ddx redim arr(s) Thanks again. "Ryan H" wrote: Is this what you are wanting? Hope this helps! If so, let me know, click "YES" below. dim arr() dim s as string s = "5, 6, 10" arr = Split(s, ",") -- Cheers, Ryan "DSH" wrote: Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think the only way you will be able to do what you want is this way...
Dim arr(), Temp() As String Dim s As String s = "5, 6, 10" Temp = Split(s, ",") Select Case UBound(Temp) Case 0 ' One dimensional array ReDim arr(Temp(0)) Case 1 ' Two dimensional array ReDim arr(Temp(0), Temp(1)) Case 2 ' Three dimensional array ReDim arr(Temp(0), Temp(1), Temp(2)) Case <<etc. ' Keep this structure going depending on the maximum needed ...... End Select -- Rick (MVP - Excel) "DSH" wrote in message ... Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Okay, I guess I will have to stick with the Select statement to do this.
Thanks. "Rick Rothstein" wrote: I think the only way you will be able to do what you want is this way... Dim arr(), Temp() As String Dim s As String s = "5, 6, 10" Temp = Split(s, ",") Select Case UBound(Temp) Case 0 ' One dimensional array ReDim arr(Temp(0)) Case 1 ' Two dimensional array ReDim arr(Temp(0), Temp(1)) Case 2 ' Three dimensional array ReDim arr(Temp(0), Temp(1), Temp(2)) Case <<etc. ' Keep this structure going depending on the maximum needed ...... End Select -- Rick (MVP - Excel) "DSH" wrote in message ... Is it possible to create a dynamic multi-dimensional array? I know the following will not work, but something to the effect: dim arr() dim s as string s = "5, 6, 10" redim arr(s) 'i.e. redim arr(5, 6, 10) Thanks. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Multi Dimensional Array | Excel Programming | |||
Multi Dimensional Array | Excel Programming | |||
Multi-Dimensional Array Let & Get | Excel Programming | |||
How to declare Multi-dimensional dynamic array? | Excel Programming | |||
Declaring Dynamic Multi-dimensional Array | Excel Programming |