Syntax for multidimensional array

G

Guest

I want to create a multidimensional array in VBA. My code is:

Dim strDataMatrix(0 To 10, 0 To 2)

Does that mean ....(rows,columns) or ....(columns,rows) ? I know how an
ordinary array works and everthing but what comes first in the
multidimensional array, the number of rows or columns? Any help very much
appreciated!

I have gooled this but with some results that do not seem coherent with
other VBA functions e.g. Offset or common mathematical notation. Therefor I
need to be sure of how it works. Thanks!
 
D

Dave Peterson

I think most people think rows by columns.

But it doesn't have to be either. Maybe it's heights and weights with nothing
to do with cells on a worksheet.

But if you're picking up the values from a worksheet range, then the first
dimension will be rows and the second columns.

dim strDataMatrix as variant
dim myRng as range

with activesheet
strDataMatrix = .range("a1").resize(11,3).value
end with

You started your array with 0, but this will be the same as:

dim strDataMatrix(1 to 11, 1 to 3) as variant

(when you pick up those values this way, excel will use base 1.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top