+ Reply to Thread
Results 1 to 12 of 12

help with sorting multidimensional array

  1. #1
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    help with sorting multidimensional array

    Hi,

    I've got a multidimensional array that I don't know how to go about sorting... I have an MxN array, and I want the columns sorted in ascending order. There are some blank fields that I'd like to ignore too. I've added an attachment as an example. The tabs are pre-sorted data, and then another tab of what the sorted data should look like.

    Thanks for your help

    multi-sort-example.xlsx

  2. #2
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: help with sorting multidimensional array

    does all the data within columns D:K belongs to NAME as well?
    or are they just independent columns of data to be sorted?

    if they are not independent, then it's wrongly sorted.
    if they are independent, how do you determine where to put blank fields? like in columns J:K, you have blanks on and off after sorted, while when before sorting they are all blanks before it comes to the data.

  3. #3
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: help with sorting multidimensional array

    D:K belongs to NAME as well.

    On the AFtering sorting tab, what do you mean that it's wrongly sorted? They are still in ascending order (with blank fields ignored).

    Utlimately what I want is for NAME to be in order, and B:K to be sorted in ascending order while ignoring blank fields.

  4. #4
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: help with sorting multidimensional array

    let's take a look at unknown3 for example, if all columns' data belongs to it, it means it has:
    Please Login or Register  to view this content.
    and after sorting, it has become:
    Please Login or Register  to view this content.
    doesn't it mean it has already lost its original data?

    OR it could be im just dumb.... or your requirements on the sorting isn't clear enough?

    Edit: also, from what i see, the column NAME isn't sort in an alphabetical order as well... so it's kind of confusing now
    Last edited by millz; 09-03-2013 at 12:25 PM.

  5. #5
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: help with sorting multidimensional array

    oh, the sorting should be the columns, not the rows.

    So, if you look at column B in the after sorting tab, it's in order. Same with C, D, E, F, etc.

    Column A, NAME, is merely the labels that go with each of the values within a column.

  6. #6
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: help with sorting multidimensional array

    The column NAME is just a label and isn't supposed to be in any alphabetical order or numerical order. It's just supposed to correspond with the values in B:K

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: help with sorting multidimensional array

    How did you achieve the sorting on the After Sorting sheet?
    If posting code please use code tags, see here.

  8. #8
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: help with sorting multidimensional array

    I did it manually.

  9. #9
    Registered User
    Join Date
    07-03-2013
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: help with sorting multidimensional array

    Sorry it appears that my previous example file wasn't quite right. I've inserted the right file. Same rules apply.

    multi-sort-example.xlsx

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: help with sorting multidimensional array

    There seems to be some difference between the pre-sorted sheets in the workbooks, but the only difference in after-shorted shees only seems to be one has Others and the other doesn't.

    Anyways, I can't see an easy way to sort as you want, the blanks being the main problem.

    You certainly can't use Excel's inbuilt sort methods, manually or in code, as it doesn't like multiple areas.

    Even writing code to sort the data isn't going to be straightforward.

  11. #11
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: help with sorting multidimensional array

    Link to solved thread, just in case any one arrived here instead.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: help with sorting multidimensional array

    So there was a duplicate thread?

+ 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. 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
  2. Row copy within multidimensional array
    By guptaraja in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-09-2010, 10:48 PM
  3. Multidimensional Array
    By sidd in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2009, 09:57 PM
  4. Multidimensional array
    By gwithey in forum Excel Programming / VBA / Macros
    Replies: 31
    Last Post: 02-02-2009, 12:15 PM
  5. Sorting a multidimensional array
    By Gromit in forum Excel General
    Replies: 0
    Last Post: 01-18-2005, 05:39 PM

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