+ Reply to Thread
Results 1 to 11 of 11

Array Formulae to Alphabetise on Two 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,421

    Array Formulae to Alphabetise on Two Columns

    Afternoon, all!

    I'm having one of my mental block moments. How do I get the two columns on the left into alphabetical order in pairs so that they look like those on the right? Must be by formula.

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    1
    2
    AAA A AAA A
    3
    BBB C AAA B
    4
    DDD A AAA C
    5
    BBB A BBB A
    6
    AAA C BBB B
    7
    AAA B BBB C
    8
    DDD C CCC A
    9
    CCC A CCC B
    10
    DDD B CCC C
    11
    CCC B DDD A
    12
    CCC C DDD B
    13
    BBB B DDD C
    Sheet: Sheet1

    Sample file attached.
    Attached Files Attached Files
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Array Formulae to Alphabetise on Two Columns

    select the columns
    click DATA on menu
    click SORT
    select your sort order, COL1, COL2

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Array Formulae to Alphabetise on Two Columns

    Hi,

    I think this will work. In D2
    =LOOKUP(1,0/FREQUENCY(ROWS($1:1),COUNTIF($A$2:$A$13,"<="&$A$2:$A$13)),$A$2:$A$13)
    in E2
    =LOOKUP(1,0/FREQUENCY(COUNTIF(D$1:D1,D2)+1,COUNTIFS($A$2:$A$13,D2,$B$2:$B$13,"<="&$B$2:$B$13)),$B$2:$B$13)
    and fill down.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  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,421

    Re: Array Formulae to Alphabetise on Two Columns

    Quote Originally Posted by ranman256 View Post
    select the columns
    click DATA on menu
    click SORT
    select your sort order, COL1, COL2
    Thanks, but I specifically stated that I need formulae for this.

  5. #5
    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,421

    Re: Array Formulae to Alphabetise on Two Columns

    Quote Originally Posted by xlnitwit View Post
    Hi,

    I think this will work. ...
    Thanks for the suggestion - I will give it a go tomorrow.

  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,421

    Re: Array Formulae to Alphabetise on Two Columns

    The first formula works perfectly, and so does the second until I tweak the data:

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    G
    H
    1
    2
    DKH Barnes AAA A BBB A
    3
    BBB C AAA B BBB Barnes
    4
    DDD A AAA C BBB C
    5
    BBB A BBB A CCC A
    6
    DKH Carroll BBB B CCC Barnes
    7
    DKH Anson BBB C CCC C
    8
    DDD C CCC A DDD A
    9
    CCC A CCC B DDD Barnes
    10
    DDD B CCC C DDD C
    11
    CCC B DDD A DKH Anson
    12
    CCC C DDD B DKH Barnes
    13
    BBB B DDD C DKH Carroll
    Sheet: Sheet1

    Any ideas?
    Attached Files Attached Files
    Last edited by AliGW; 10-11-2017 at 04:45 AM.

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Array Formulae to Alphabetise on Two Columns

    Oh dear!

    Perhaps this in E2 instead
    =LOOKUP(1,0/FREQUENCY(ROWS($1:1),MMULT(--($A$2:$A$13&$B$2:$B$13>=TRANSPOSE($A$2:$A$13&$B$2:$B$13)),ROW(INDIRECT("A1:A"&ROWS($A$2:$A$13)))^0)),$B$2:$B$13)
    which must be array entered.

    A helper column concatenating the names might make life simpler? You could use
    =LOOKUP(1,0/FREQUENCY(ROWS($1:1),MMULT(--($A$2:$A$13&$B$2:$B$13>=TRANSPOSE($A$2:$A$13&$B$2:$B$13)),ROW(INDIRECT("A1:A"&ROWS($A$2:$A$13)))^0)),ROW($B$2:$B$13))
    to return the required row number and then use two simple INDEX formulas.
    Last edited by xlnitwit; 10-11-2017 at 05:20 AM.

  8. #8
    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,421

    Re: Array Formulae to Alphabetise on Two Columns

    Thanks again. I'll try this when I get to work.

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,618

    Re: Array Formulae to Alphabetise on Two Columns

    This also works for E2.
    ARRAY formula

    =INDEX($B$2:$B$13,MATCH(COUNTIF($J$2:$J2,$J2),MMULT(--(IF($A$2:$A$13=J2,$B$2:$B$13,"")>=TRANSPOSE(IF($A$2:$A$13=J2,$B$2:$B$13,REPT("Z",20)))),--(ROW($A$2:$A$13)>0)),0))
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  10. #10
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,844

    Re: Array Formulae to Alphabetise on Two Columns

    A bit shorter here. Arrayformulas of course.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  11. #11
    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,421

    Re: Array Formulae to Alphabetise on Two Columns

    Thank you all. Case closed.

+ 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. Error with array formulae
    By Throughstream in forum Excel General
    Replies: 4
    Last Post: 04-30-2017, 04:14 AM
  2. Alphabetise
    By Throughstream in forum Excel General
    Replies: 2
    Last Post: 01-25-2017, 03:20 AM
  3. [SOLVED] Array formulae with different sized array, e.g. array-if() or somproduct-if()?
    By hlhans in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-09-2016, 03:59 PM
  4. Using Variable array formulae
    By empsall in forum Excel General
    Replies: 8
    Last Post: 08-08-2009, 01:39 PM
  5. Array Formulae
    By kbsudhir in forum Excel General
    Replies: 1
    Last Post: 05-05-2009, 02:17 PM
  6. alphabetise
    By ignus99 in forum Excel General
    Replies: 5
    Last Post: 06-02-2005, 08:05 PM
  7. [SOLVED] OFFSET and array formulae
    By Wazooli in forum Excel General
    Replies: 3
    Last Post: 01-19-2005, 09:06 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