+ Reply to Thread
Results 1 to 11 of 11

New to arrays-where do I find a good beginners guide to multi dimensional arrays

  1. #1
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    New to arrays-where do I find a good beginners guide to multi dimensional arrays

    I am making tentative steps in 1D & 2D arrays. I now have need to build a 3D array from a workbook. Is there any good web page that you can recommend for learning this?


    Alternatively, could some kind forum user provide code for a project level function that I can run on a workbook to build a 3D array? (As an example of what I mean, I have provided two functions below which will create a 1or2D array if you provide the right worksheet arguments)

    Please Login or Register  to view this content.
    Last edited by mc84excel; 06-04-2013 at 07:47 PM.
    *******************************************************

    HELP WANTED! (Links to Forum threads)
    Trying to create reusable code for Custom Events at Workbook (not Application) level

    *******************************************************

  2. #2
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    I don't know if this helps or not. Maybe it's too basic.

    Think of a chess (or checker) board as a 2D array. You would dimension it 8x8. (Dim MyArray 1 to 8, 1 to 8)

    MyArray(1,1) would be the upper left square, MyArray(8,8) would be the lower right square etc.

    So now, a 3D Array is simply one or more chessboards on TOP of the first one. If you just have ONE extra board (for a total of 2) your array looks like this: MyArray(1 to 2, 1 to 8, 1 to 8).

    If you want to refer to a cell location on the TOP board, you would reference it like this: MyArray(1, 4, 3)

    If you're referring to the cell same location on the board underneath it, you reference it with a 2 instead of a 1, like this: MyArray(2, 4, 3)

    If you've got 100 chessboards, the very last board, and the very corner cell, would be MyArray(100, 8, 8)


    That might help to understand the "concept" of multidimensional arrays.

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    Thanks +1

    It's not so much the concept I am struggling with (btw I think of 2D arrays as a worksheet range and a 3D array as a workbook containing sheets which contain ranges), but how would I go about building a 3D array from a given workbook?

  4. #4
    Valued Forum Contributor
    Join Date
    03-21-2013
    Location
    cyberia
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    are you doing something like trying to specify the cell in the i-th row of the j-th column of the k-th worksheet?

    so you find say its value by MsgBox Array_3D(17, 3, 4).value, or its format, or whatever?

  5. #5
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    hi kalak: no, not that advanced yet. I'm just trying to build a 3D array from a workbook at the moment. Similar to the code I provided in post #1 - which creates a 2D (or 1D) array from the worksheet contents. (It assumes sheets contain data tables starting from cell A1 outwards)

    I am interested in 3D arrays because the 2D array builder code in post #1 is very useful to me in a current project. However it means I need to grab a 2D array from each sheet one by one. If I had a 3D array, I could grab all the sheets 2D arrays in one go - an array of 2D arrays.

  6. #6
    Forum Contributor
    Join Date
    10-13-2012
    Location
    Southern California
    MS-Off Ver
    Excel 2007
    Posts
    401

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    So basically, let's say your workbook has 10 sheets. Each sheet has, of course, data in the rows and columns. And as you say, each sheet is like a 2D array. So what you do is create a 3D array that's dimensions like this: MyArray(1 to 10, 1 to max_rows, 1 to max_columns)

    Max_rows is the number of rows you have, in whatever worksheet that has most rows.
    Max_columns is the number of columns you have, in whatever worksheet that has most columns.
    And, of course, 1 thru ten indicates each individual worksheet in this workbook.

    So you loop through all ten worksheets, incrementing the loop counter each time, and each time copying the data from all the rows and columns of each worksheet into the array. Something like this:

    Please Login or Register  to view this content.
    How's that?

    If you have lots and lots of data, turn application screenupdating off, and also go make yourself a cup of coffee while it's running.

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    3D array is not feasible IMO.

    I'd go with Jugged array (arrays in an array)
    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    Quote Originally Posted by Ed_Collins View Post
    Something like this:
    Thanks for this Ed +1 (Actually I don't want each of the 'sheet' arrays to have the same size - but this is definitely a start)

  9. #9
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    Quote Originally Posted by jindon View Post
    I'd go with Jugged array (arrays in an array)
    Hello jindon - what is a Jugged array? (I've only recently started to grasp 1D & 2D arrays) How is it different to a 3D array?

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    3D array have fixed size in 1 st & 2 nd dimention.

    Whereas Jugged array (arrays in an array) can have flexible size of arrays as an element of main array.

  11. #11
    Valued Forum Contributor
    Join Date
    08-29-2012
    Location
    In lockdown
    MS-Off Ver
    Excel 2010 (2003 to 2016 but 2010 for choice)
    Posts
    1,766

    Re: New to arrays-where do I find a good beginners guide to 3D arrays?

    Quote Originally Posted by jindon View Post
    3D array have fixed size in 1 st & 2 nd dimention.

    Whereas Jugged array (arrays in an array) can have flexible size of arrays as an element of main array.
    Thanks for explaining that (and for the code) +1

    I think I want the latter (rather than a true 3D array)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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