+ Reply to Thread
Results 1 to 19 of 19

Using an array formula to sort alphabetically over multiple columns

  1. #1
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Using an array formula to sort alphabetically over multiple columns

    I've often found answers to queries here, but not posted until today. I'm looking for some help with an array formula, having started using these only two days ago.

    In the attached example file, I have two tabs: options and sets. The options tab is to be populated from a form. The sets tab is to draw data from the options tab to create teaching sets. I have managed to create an array formula that does this for me, but what I would like it to do is sort my resulting list alphabetically. For reasons that I won't go into, I need the data on the sets tab to remain in three columns: First Name, Surname and Form.

    This is the array formula I am using at the moment:

    Please Login or Register  to view this content.
    Is anyone able to help me adapt the attached workbook to work in the way I would like, please?

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Using an array formula to sort alphabetically over multiple columns

    Please have a look on the below thread and come back,
    http://www.excelforum.com/excel-gene...-formulas.html

  3. #3
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    Hello and welcome ! you need to use your main results which you have generated as helper and based on that you can apply another formulaand sort the list ! Find attached

    you can hide your main results afterwards

    In Cell A1 write French
    copy paste below in B2 then drag down and drag to right(Array entered)

    =IF(ISERROR(INDEX(Options!$A$4:I98,SMALL(IF(Options!$H$4:$H$98=$A$1,ROW(Options!$H$4:$H$98)),ROW(1:1))-3,COLUMN(A1))),"",INDEX(Options!$A$4:I98,SMALL(IF(Options!$H$4:$H$98=$A$1,ROW(Options!$H$4:$H$98)),ROW(1:1))-3,COLUMN(A1)))
    Attached Files Attached Files
    Last edited by hemesh; 02-14-2014 at 03:53 AM.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    @hemesh - Many thanks for trying to help, however your suggested answer is ordering the columns individually. Look again at the example workbook you posted - first names are with the incorrect surnames and forms. I should have said that I had already discovered how to order one column alphabetically using the formula you proposed, but it's multi-column ordering that I need to do.

    @chinraj - Thank you, but I don't see how the thread you suggested links to my exact problem.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Using an array formula to sort alphabetically over multiple columns

    Hi,

    You don't say on which field the alphabetic sorting should be based. Surname, I presume?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by XOR LX View Post
    Hi,

    You don't say on which field the alphabetic sorting should be based. Surname, I presume?

    Regards
    Yes - surname, then first name (as there may be more than one with any given surname). Thanks for looking!

  7. #7
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Using an array formula to sort alphabetically over multiple columns

    Thanks. I notice your profile says 2010 yet you are currently using a construction (IF(ISERROR)) which seems to suggest that this needs to be compatible with 2003 - is this correct? If not, we can simply somewhat with IFERROR().

    Regards

  8. #8
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    Try this
    =INDEX(B$2:B$100,MATCH(SMALL(IF(COUNTIF($B$2:$B$100,"<="&$B$2:$B$100)>0,COUNTIF($B$2:$B$100,"<="&$B$2:$B$100)),ROW(A1)),COUNTIF($B$2:$B$100,"<="&$B$2:$B$100),0))

    Array ENtered f2 drag down and to right

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by XOR LX View Post
    Thanks. I notice your profile says 2010 yet you are currently using a construction (IF(ISERROR)) which seems to suggest that this needs to be compatible with 2003 - is this correct? If not, we can simply somewhat with IFERROR().

    Regards
    No, it does not need to be compatible with 2003 - I'm using 2010 at work and at home. Thanks!

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by hemesh View Post
    Try this
    =INDEX(B$2:B$100,MATCH(SMALL(IF(COUNTIF($B$2:$B$100,"<="&$B$2:$B$100)>0,COUNTIF($B$2:$B$100,"<="&$B$2:$B$100)),ROW(A1)),COUNTIF($B$2:$B$100,"<="&$B$2:$B$100),0))

    Array ENtered f2 drag down and to right
    Nearly there, thank you! I need the columns ordered by surname first, then first name. This, I find, works:
    Please Login or Register  to view this content.
    Problem solved - thanks again!!!

  11. #11
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    Check This here is the sorted version of options ! in second sheet you can create formula based on sorted
    Attached Files Attached Files

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by hemesh View Post
    Check This here is the sorted version of options ! in second sheet you can create formula based on sorted
    Thank you, but I have solved the issue by tweaking the formula you suggested in your previous post. I did not want the sorting to happen on the Options tab, anyway.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by XOR LX View Post
    Thanks. I notice your profile says 2010 yet you are currently using a construction (IF(ISERROR)) which seems to suggest that this needs to be compatible with 2003 - is this correct? If not, we can simply somewhat with IFERROR().

    Regards
    You learn something new every day - thanks again!

  14. #14
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    Hello ! I realized a little bit later that the formula won't be fetching if there is any duplicate entry in surname ! But here is the modified version. find attached.
    on sets sheet is the new formula and on options sheets the formula is earlier one. You can see the difference.
    Attached Files Attached Files

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by hemesh View Post
    Hello ! I realized a little bit later that the formula won't be fetching if there is any duplicate entry in surname ! But here is the modified version. find attached.
    on sets sheet is the new formula and on options sheets the formula is earlier one. You can see the difference.
    Thanks again. This is driving me nuts! I want to have the first name column before the surname column, and I am very carefully copying and tweaking the formula, but I can't get it to work.

  16. #16
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    You can just change the heading of surname to first names In new post with name fetching duplicate data also

    =IFERROR(INDEX($B$2:$D$100,MATCH(SMALL(IF($A$2:$A$100>0,$A$2:$A$100),ROW(A1)),$A$2:$A$100,0),MATCH(F$1,$B$1:$D$1,0)),"")
    red part brings the column to be fetched.

    as you can see it matches first Name with First name in another column

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by hemesh View Post
    You can just change the heading of surname to first names In new post with name fetching duplicate data also

    =IFERROR(INDEX($B$2:$D$100,MATCH(SMALL(IF($A$2:$A$100>0,$A$2:$A$100),ROW(A1)),$A$2:$A$100,0),MATCH(F$1,$B$1:$D$1,0)),"")
    red part brings the column to be fetched.

    as you can see it matches first Name with First name in another column
    Gotcha! That's what I was missing - thanks. Will try this out later and let you know.

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,440

    Re: Using an array formula to sort alphabetically over multiple columns

    Quote Originally Posted by AliGW View Post
    Gotcha! That's what I was missing - thanks. Will try this out later and let you know.
    Yes, that was it. I understand the formula now and everything is working as it should. Thank you once again!

  19. #19
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Using an array formula to sort alphabetically over multiple columns

    Thanks for the feedback and Rep.

+ 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. Pick multiple items from list and sort alphabetically in single cell
    By kawale in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-07-2021, 01:48 PM
  2. Alphabetically auto sort columns
    By higguns in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-22-2013, 12:16 PM
  3. [SOLVED] Sort Array Alphabetically
    By gsurge in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-04-2012, 12:03 PM
  4. Alphabetically Sort Columns Using Top Row
    By ryevick in forum Excel General
    Replies: 3
    Last Post: 12-30-2008, 12:40 PM
  5. UDF to sort array with multiple columns
    By flygis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-02-2006, 01:10 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