Multidimensional array question.

eduzs

Well-known Member
Joined
Jul 6, 2014
Messages
704
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
My code is something like:

VBA Code:
Dim str1 as string, str2 as string, aMyArray
str1="A,B"
str2="C,D"
MyArray=(split(str1,","),split(str2,",",")

To retrieve the array values, I expected to use this: MyArray(0,0) should be = "A", MyArray(0,1)="B"
But I found that I can only retieve using this:
Msgbox MyArray(0)(0)
I didn't understand why it only works with "MyArray(0)(0)" and not "MyArray(0,0)" as I see everywhere?????
Is that something wrong or not ideal in my code?
Thanks.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I get a syntax error on this line:
MyArray=(split(str1,","),split(str2,",",")
which highlights the comma between the first split and the second split. This is because what you appear to be trying to do is create an array of two single dimension arrays, i.e an array of arrays If your version of EXCEL manages to sort that out then the addressing would be as you have found. the addressing myarray(0,0) implies a single two dimension array
I am using EXCEL 2010
 
Upvote 0
Array arrays is not supported by Office 2010?
Thank you! I will need to modify the code.
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top