+ Reply to Thread
Results 1 to 2 of 2

Syntax for multidimensional array

  1. #1
    Arne Hegefors
    Guest

    Syntax for multidimensional array

    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!



  2. #2
    Dave Peterson
    Guest

    Re: Syntax for multidimensional array

    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.)



    Arne Hegefors wrote:
    >
    > 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!


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1