+ Reply to Thread
Results 1 to 8 of 8

Custom Sort: By Last name but keep different last names together

  1. #1
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Custom Sort: By Last name but keep different last names together

    Please and thank you to the group...

    I have a list of members. Column A is Member Number. Column B is Member Letter. Column C is Last Name, Column D is First Name.

    It looks like this;

    12345 0 Smith John
    12345 A Smith Jane
    12345 B Smith Bobby

    So far so good, everything is sorted properly. HOWEVER, if a spouse has a last name different than the rest of the family, that person gets sorted separately from the rest. I would like to sort the entire list by Last Name then Member Number, then Member Letter AND keep the families together regardless of last name so it would look like the below example.

    12345 0 Smith John
    12345 A Smith Jane
    12345 B Smith Bobby
    54321 0 Young Alan
    54321 A Jones Betty
    54321 B Young Joe
    Last edited by argentraven; 05-30-2019 at 06:37 PM.

  2. #2
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,267

    Re: Custom Sort: By Last name but keep different last names together

    1. In the column "B" letters were supposed to be, but there are also digits 0 ...
    2. Why (for 54321) are Young-Jones-Young and not Jones-Young-Young, sorting was to be by: Last Name then Member Number then Member Letter
    3. And what about sorting by first name - referring to point 2 ?

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

    Re: Custom Sort: By Last name but keep different last names together

    If you sort your second example first by Member Number and then by Last Name you get the exact order that you have specified - at least for this one example. This relies on family members having the same Member Number as is the case in your example. If this does not do what you want then please provide a further more general example.
    Geoff

    Did I help significantly? If you wish, click on * Add Reputation to say thanks.
    If your problem has been resolved please select ?Solved? from the Thread Tools menu

  4. #4
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: Custom Sort: By Last name but keep different last names together

    My apologies for not being more clear.

    In column B the zero is so that the primary member sorts first before the secondary and lower members in a given membership. for example;

    12345 0 John Doe (Primary member)
    12345 A Jane Doe (Spouse)
    12345 B Jimmy Doe (Child)

    When a spouse has a different name than the primary member, we want that spouse to fall in line under the primary member, then list dependents such as with the Young-Jones-Young example.

    Currently, when I sort by Last Name then member number, I get the Young-Jones-Young order, HOWEVER, it still lists in member number order. I want the list to ultimately be in alpha by last name but with the spouses with different last names properly associated with their primary member. Something like this;

    12345 0 Aaron Bob
    12345 A Aaron Betty
    12345 B Aaron Billy
    22650 0 Adams Larry
    22650 A Carter Karen
    22650 B Adams Julie
    12240 0 Allen David
    12240 A Allen Susan
    36920 0 Bishop Mike
    36920 A Bishop Gloria

    As you can see in this example, Larry Adams and Karen Carter are married, but with different last names and she is listed with her family even though her last name is different. Ultimately the list is in alpha and I do not care if the member numbers are out of order.

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

    Re: Custom Sort: By Last name but keep different last names together

    I just don't see a way to get Excel's sort capability to handle this.

    How about the following alternate approach?

    Add a new "Sort order" column and have it populated it with numbers reflecting your desired sort order. This can be done more or less automatically as follows:

    I assume you have headers is row 1 and col-A is your newly created sort order column and ID, Letter, Last name and First name are in cols B, C, D and E respectively.

    1. Sort your member list by last name - important!
    2. Put the following formula in A2. Note that this is an array formula and must be committed with CTRL-SHIFT-ENTER
      Formula: copy to clipboard
      Please Login or Register  to view this content.
    3. Copy the A2 formula down as far as necessary
    4. This generates a sort key in col-A ordered as you require.
    5. Select col-A, copy, paste-values.
    6. Now sort by col-A and your member list should be ordered as you require.

    The attached workbook uses your latest test data and reflects the above process just prior to the copy / paste-values step.

    Let me know if this works for you.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,267

    Re: Custom Sort: By Last name but keep different last names together

    Maybe something like that, in F2:
    Please Login or Register  to view this content.
    copy down, then sort.
    Attached Images Attached Images

  7. #7
    Registered User
    Join Date
    04-30-2010
    Location
    Pebble Beach, California
    MS-Off Ver
    2016
    Posts
    44

    Re: Custom Sort: By Last name but keep different last names together

    GeoffW283, that worked really well!!

    Thank you!!

    Also, thank you to everyone that responded. This community is awesome!

    Regards,
    Gerry

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

    Re: Custom Sort: By Last name but keep different last names together

    Glad it worked out for you. Thanks for the feedback and rep

    >>> EDIT: porucha vevrku's solution does the same thing as mine but in a much much more straightforward manner. The only limitation is that it's currently limited to 4 family members, but his formula is easily extensible to fix that if necessary.
    Last edited by GeoffW283; 05-31-2019 at 05:59 PM.

+ 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 custom sort orders with Range().sort
    By WestWindsDemon in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-21-2018, 03:52 PM
  2. Replies: 5
    Last Post: 05-09-2017, 08:48 AM
  3. Using Cell References As PivotItem names to Custom Sort PivotTable
    By brndnr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2015, 01:49 AM
  4. Challenged: ascending sort within custom sort
    By jhren in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-10-2013, 12:35 PM
  5. Replies: 5
    Last Post: 01-13-2012, 03:20 PM
  6. Excel sort by Fill Color by custom list sort
    By Dash4Cash in forum Excel General
    Replies: 2
    Last Post: 07-29-2005, 06:05 PM
  7. Custom sorting-sort the names
    By kexcelf in forum Excel General
    Replies: 0
    Last Post: 03-29-2005, 04:18 AM

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