+ Reply to Thread
Results 1 to 14 of 14

Sorting a list/values that are spread out over multiple columns

  1. #1
    Registered User
    Join Date
    10-15-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    5

    Sorting a list/values that are spread out over multiple columns

    I am trying to alphabetically sort a list that spans multiple columns in Excel and while it seems like an easy task, I have not found a way to do it. For argument's sake, let's say there are 9 cells/values in the list and that it begins in A1 and ends in C3. I can sort any row or column, but I'd like to sort the entire range so that the lowest value is in A1 and the highest value is in C3. Multicolumn lists can be sorted with relative ease in Word, I expect because the list is interpreted as a table. Perhaps the solution lies therein?

    Thank you!

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2506 Win 11
    Posts
    24,901

    Re: Sorting a list/values that are spread out over multiple columns

    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,715

    Re: Sorting a list/values that are spread out over multiple columns

    Hi
    A forum guru might find a more elegant solution, but this macro seems to work.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-15-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Sorting a list/values that are spread out over multiple columns

    Hi Alan, attached are what the data looks like before and what I'd like it to look like afterwards.
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,715

    Re: Sorting a list/values that are spread out over multiple columns

    Ah
    my previous macro assumed numbers not strings
    try this one:

    Please Login or Register  to view this content.

  6. #6
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Sorting a list/values that are spread out over multiple columns

    Hi HP. Welcome to the forum.

    In the attached find this array formula in E1 filled down and across. If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    A
    B
    C
    D
    E
    F
    G
    1
    dog
    shoe
    bear
    ball
    cat
    keys
    2
    sweater
    cat
    keys
    bear
    dog
    shoe
    3
    car
    house
    ball
    car
    house
    sweater
    Dave

  7. #7
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Sorting a list/values that are spread out over multiple columns

    Another way. This doesn't have to be array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-15-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Sorting a list/values that are spread out over multiple columns

    NickyC, that worked like a charm, thank you!

    FlameRetired, I can see that your formula works as well (from downloading your file). I haven't quite figured out how to insert the formula on my own spreadsheet, let me keep looking, I'm sure I can figure it out.
    Last edited by alansidman; 10-16-2018 at 12:07 AM. Reason: Add to post

  9. #9
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Sorting a list/values that are spread out over multiple columns

    OK.

    In the meantime here's another way ... non array entered.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by FlameRetired; 10-16-2018 at 12:14 AM.

  10. #10
    Registered User
    Join Date
    10-15-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Sorting a list/values that are spread out over multiple columns

    Thanks FlameRetired. OK, I see how it works using the formula. Your way is very specific and does exactly what I showed in the before and after spreadsheet. If I want to adapt it, I just change the values of the starting cell in the formula where I want the sorted table to begin and the paste the formula in the new sorted table cells. The macro that NickyC sent had the added advantage of being a little more generic/versatile but for very specific examples, yours works perfectly. Thank you for the original and improved formulas, I really appreciate your help!!

  11. #11
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2506
    Posts
    13,792

    Re: Sorting a list/values that are spread out over multiple columns

    Yes it was specific.

    This formula will adapt to the source starting anywhere in the sheet. In fact I applied it to the original location for the source data and then moved the source data to a "random" location D14:F16 and the formula returned as intended.
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    My apologies for the oversight.

  12. #12
    Registered User
    Join Date
    10-15-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    5

    Re: Sorting a list/values that are spread out over multiple columns

    Quote Originally Posted by NickyC View Post
    Ah
    my previous macro assumed numbers not strings
    try this one:

    Please Login or Register  to view this content.
    Hey NickyC, would it be possible with a small tweak to sort the words going down the column first and then over to the next column vs going across the the row first and then down to the next row? So for example if the sorted list began in A1 and ended in C3, the lowest value would be in A1, the next lowest value would be in A2, the next lowest would be in A3, the next lowest would be in B1, and so forth. Thank you!! :-)
    Last edited by HandsomePrints; 10-19-2018 at 12:12 AM. Reason: Clarification

  13. #13
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,715

    Re: Sorting a list/values that are spread out over multiple columns

    Hi
    apologies for not getting back to you sooner - try this

    Please Login or Register  to view this content.

  14. #14
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Sorting a list/values that are spread out over multiple columns

    Here is a derivative of FlameRetired's post #6 formula that is a little shorter and simpler and - as far as I can see - still works correctly. As with the formula in post #11 this formula will automatically adapt to the source starting anywhere in the sheet. There is also no need to enter it as an array formula.

    Another consideration in putting this to practical use would be how the formula would have to change if the number of rows and/or columns in the source data were to change. Obviously all $A$1:$C$3 references must be changed as necessary. In addition the 3 in "*3" (both instances) must be changed to the number of rows in the source data. The number of elements in the {1;1;1} vertical array constant must be changed to the number of columns in the source data and the number of elements in the {1,1,1} horizontal array constant must be changed to the number of rows in the source data. Similar considerations would apply to the other formulas noted above.

    Finally note that I think there is a limitation that all of these formulas break if there is a cell in the source data that is numeric rather than alpha.

    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ 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. Pull values from Multiple columns that are spread apart
    By Dodie9 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-16-2015, 06:24 AM
  2. Replies: 0
    Last Post: 01-19-2015, 03:31 PM
  3. Replies: 0
    Last Post: 10-02-2012, 09:09 AM
  4. Sorting columns by row values via a dropdown list
    By RedWing in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-07-2011, 06:30 AM
  5. Sorting a list of numbers by multiple columns
    By acedie in forum Excel General
    Replies: 2
    Last Post: 10-14-2008, 11:27 AM
  6. Sorting alphabetical list into multiple columns
    By jp1733 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-15-2006, 08:20 PM
  7. Sorting multiple columns as 1 list alphabetically?
    By philpott in forum Excel General
    Replies: 4
    Last Post: 10-19-2005, 02:05 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