LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Make an Array 2-dimensional in VBA

Because all the the array element are 2D other than (35), I was wanting
to know if there is a way to use the Array function to make it 2D?


I haven't been following this thread nor the logic behind your code;
however, I did want to address this question for you. There is a way to do
what you ask... sort of. This will only work with variables declared as
Variant (which is the case for your question), but the syntax will be a
little funny. Here is an example for a normal Variant variable, but you can
apply the technique to your array of Variants as well (you will just have an
extra set of parentheses for the Variant array index in addition to the ones
shown below). Note, that while not necessary, I have assumed a "pure"
multi-dimensional array in which there are the same number of columns in
each row.

Sub Test()
Dim Row As Long
Dim Col As Long
Dim V As Variant
'
' Assign a 3 by 4 array to Variant variable V
'
V = Array(Array(1, 2, 3), Array("A", "B", "C"), _
Array(5, 6, 7), Array("D", "E", "F"))
'
' Let's see the result of that assignment; and notice
' the double parentheses method of referencing the
' multi-dimensional array - V(Row)(Col)
'
Debug.Print "Row Col Value"
For Row = LBound(V) To UBound(V)
For Col = LBound(V(LBound(V))) To UBound(V(UBound(V)))
Debug.Print " " & Row & " " & Col & " " & V(Row)(Col) & _
" " & "V(" & Row & ")(" & Col & ")"
Next
Next
End Sub

--
Rick (MVP - Excel)

 
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
Export 1-dimensional array values to a two-dimensional table? Laurie Excel Programming 2 November 8th 07 03:51 PM
Changing a two-dimensional, one row array to one-dimensional Alan Beban[_2_] Excel Programming 1 September 16th 07 08:56 PM
Returning an array from a multi-dimensional array Chris Excel Programming 2 January 3rd 07 06:01 AM
Mutli-dimensional Array to Single-Dimension Array Blue Aardvark Excel Programming 3 October 15th 05 09:22 AM
Create One-Dimensional Array from Two-Dimensional Array Stratuser Excel Programming 1 February 23rd 05 08:46 PM


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