+ Reply to Thread
Results 1 to 9 of 9

Multidimensional Array vs (extended) One dimensional Array

  1. #1
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Multidimensional Array vs (extended) One dimensional Array

    Could anyone advise me which approach, if either, is a more efficient/better option...

    I want to loop though some rows on a worksheet and add the values in 6 cells to an array. Would there be any advantage to either creating an array with 6 columns, or having a single column array and simply adding the next 6 values from each row underneath the previous. So for example, the values from two rows would create either a 2x6 array, or a 1x12 array.

    It's the same amount of values, but I'm thinking that a single column array would be easier to navigate when performing subsequent actions and perhaps memory wise a single, albeit longer, column might be more efficient? I guess also a single column array could be better done as a collection, if that would make any difference?

    Thanks in advance.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multidimensional Array vs (extended) One dimensional Array

    Wrong Approach

    Load an Array with 1200 Values
    Please Login or Register  to view this content.

    Loop through 1200 entries in the Array and count how many "Apples" are in the Array
    Please Login or Register  to view this content.
    Loop through 1200 entries in the Array and count how many "Apples" are in Column 3 of the Array
    Please Login or Register  to view this content.
    Last edited by mehmetcik; 04-17-2019 at 03:20 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Multidimensional Array vs (extended) One dimensional Array

    Thank you, very helpful. In terms of speed and efficiency though, would dealing with a single column array be any 'better' that a multi column array, or would there be no real difference?

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multidimensional Array vs (extended) One dimensional Array

    It really depends on what you are trying to do.

    However if your Data is in 1200 rows of 6 columns what advantage would there be in listing your data into a one dimensional array of 7200 entries?

    At the same time how would you find a specific value in the third column of an array of 1200 rows and 6 columns

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Multidimensional Array vs (extended) One dimensional Array

    Both the targeted rows and columns in my data are non contiguous.

    So I will be looping down rows on the worksheet to find a certain value, then for any matching rows I will then add the values in say columns C, F, H, M etc. to the array.

    I'm currently unsure exactly what actions I will need to then perform on the array. So potentially I won't need to target specific positions as per your second Apple count example.

    It's not an issue for me to do it either way, but I was thinking for simplicity if I was to just add all the values one after another to a single column, I know they'll be in 'groups' of 6 so if I need to output back to a worksheet either all, or just the values in position 6 for example, then that will still be easy enough to do.

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multidimensional Array vs (extended) One dimensional Array

    So I will be looping down rows on the worksheet to find a certain value, then for any matching rows I will then add the values in say columns C, F, H, M etc. to the array.

    Which column will you be looking at?

    Do you realise that each time you read / write between VBA and Excel you are adding significant delays.

  7. #7
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Multidimensional Array vs (extended) One dimensional Array

    So is it better, for example, to just add all the values from columns C:M in each matching row to the array, and then just deal with the individual columns I need and ignore the others?

  8. #8
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Multidimensional Array vs (extended) One dimensional Array

    Correct. Just try to keep it as simple as possible.

  9. #9
    Forum Contributor
    Join Date
    10-30-2014
    Location
    England
    MS-Off Ver
    2007 / 365
    Posts
    279

    Re: Multidimensional Array vs (extended) One dimensional Array

    Great, thanks, I'll work on that principle then.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] have 1 dimensional array, trying to create a 2 dimensional array, runtime 9
    By dmcgov in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-21-2019, 07:03 AM
  2. [SOLVED] Storing Array to Find Replace Value via 2 Dimensional Array
    By Matty5894 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-19-2016, 05:53 AM
  3. Help converting one-dimensional array to multi-dimensional array
    By puzzlelover22 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2016, 06:48 AM
  4. Parse Data from one dimensional array into a 2 dimensional array.
    By JapanDave in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-30-2016, 07:29 AM
  5. Replies: 6
    Last Post: 09-25-2013, 10:08 PM
  6. Using the ReDim array function in a multidimensional array in excel
    By Doruli in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2012, 01:43 PM
  7. Mutli-dimensional Array to Single-Dimension Array
    By Blue Aardvark in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2005, 05:05 AM

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