Share via

Alphabetical sorting

Ron Lambros 0 Reputation points
2026-05-19T14:22:24.1966667+00:00

I have a list of names I'm trying to sort by LAST name in Excel, but it is sorting by FIRST name. How do I do it?

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments

3 answers

Sort by: Most helpful
  1. IlirU 2,491 Reputation points Volunteer Moderator
    2026-05-20T04:26:21.0566667+00:00

    User's image

    Hi @Ron Lambros ,

    Try this formula:

    =LET(name, A2:A11, SORTBY(name, BYROW(name, LAMBDA(a, REGEXEXTRACT(a, "[A-Z][a-z]+$")))))
    

    HTH

    IlirU

    Was this answer helpful?

    0 comments No comments

  2. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2026-05-19T23:01:28.94+00:00

    Hi,

    In cell B2, enter this formula

    =SORTBY(A2:A3,TEXTAFTER(A2:A3," ",-1),1)

    Hope this helps.

    User's image

    Was this answer helpful?

    0 comments No comments

  3. Hendrix-C 17,580 Reputation points Microsoft External Staff Moderator
    2026-05-19T15:20:29.1866667+00:00

    Hi @Ron Lambros,

    According to your concern, may I confirm whether you have first name and last name in different columns or you have full name in one column?

    If you have full name in one column, Excel will by-design sort from the beginning of the text which means sorting by first name. In this case, you need to create a helper column that extracts last name then sort by that column.

    For example, I have a sample of names like this:

    User's image

    • Starting from cell B1, I use the formula =TEXTAFTER(A1," ",-1) and copy it down to extract the last name column

    User's image

    • Then select both column A and B then choose Sort By column B in Alphabetical order.

    This is just an example in my testing worksheet. For the best assistance, please share a screenshot or sample data of your current worksheet so I can clearly understand the data structure to provide the most appropriate guidance and formula for your concern.

    Please understand that my initial response may not always resolve the issue immediately. However, with your help and more detailed information, we can work together to find a solution. 

    Thank you for your understanding and cooperation. I look forward to hearing from you.


    If you have extra questions, please click "Comment".       

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.