Excel Sorting by text, not number (10 sorted before 2)

Anonymous
2023-04-28T00:11:23+00:00

Hello,

I am trying to sort file numbers that include the year and have been unsuccessful in getting it to sort by number rather than text. I tried changing the value from general & text to number with no luck. I tried text to column. I even tried a Value(Mid(Find)) formula.

Any help is appreciated.

Here's a sample of the number that refuse to get in line. Depending on who completed the data entry, some years have leading zeros and others don't.

82-8505

82-8623

82-9065

82-9298

83-1160

83-1306

83-1390

83-18170

83-2056

83-2438

83-3286

83-9210

83-9406

84-0407

84-07636

84-07668

Microsoft 365 and Office | Excel | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Andreas Killer 144K Reputation points Volunteer Moderator
    2023-04-28T14:22:46+00:00

    B1: =SORTBY(A1:A16,VALUE(LEFT(A1:A16,2)),1,VALUE(MID(A1:A16,4,99)),1)

    1 person found this answer helpful.
    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. Anonymous
    2023-04-28T21:25:37+00:00
    0 comments No comments
  2. Andreas Killer 144K Reputation points Volunteer Moderator
    2023-04-29T07:17:43+00:00

    Thank you!!! I think I understand most of the formula, but would you mind explaining how it works?

    The first step is to get the part before the dash using LEFT, but that returns a text. We need a number to sort the "items" as desired, therefore surround with VALUE.

    VALUE(LEFT(A1:A16,2))

    The second step is to get all chars after the dash and also convert into a number.

    VALUE(MID(A1:A16,4,99))

    If you would put that formulas into separate columns you can sort all data by these columns and get the result you expect.

    You asked just to sort the items without any data in adjacent columns, so we can surround the formulas above with SORTBY.

    That's it. Any further questions?

    Andreas.

    0 comments No comments
  3. Anonymous
    2023-05-01T18:41:40+00:00

    Nope, I see it now. Thank you!!

    0 comments No comments