+ Reply to Thread
Results 1 to 2 of 2

Sorting by number values

  1. #1
    Registered User
    Join Date
    12-29-2012
    Location
    *
    MS-Off Ver
    Excel 2010
    Posts
    43

    Sorting by number values

    I have a column with the text and letters that look like this"


    Protocol 01
    Protocol 02

    and so on to protocol 155

    When i use this macro to sort it doesn't put them into the proper order. Example it will put Protocol 10 and Protocol 110 in consecutive order vs protocol 110 being much further in the column. I searched this forum for more than an hour looking for a fix.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Sorting by number values

    you will need the code to pad out the number. so protocol 01 becomes protocol 0001 and protocol 150 becomes protocol 0150
    so when sorted it will do it correctly,not that i know how to do that! i can do it with a formula
    in another column put
    =LEFT(A1,FIND(" ",A1))&TEXT(MID(A1,FIND(" ",A1)+1,10),"0000") where a1 is your first cell with protocol xx in ,fill down then sort by that
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Sorting by number values

    ie data you want to sort at A1:A155
    the result at B1:B155
    the first formula at B1 (array formula)
    {="protocol "&TEXT(SMALL(--SUBSTITUTE($A$1:$A$155;"protocol";"");ROW(1:1));"00")}
    copy down

  4. #4
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Sorting by number values

    ie data you want to sort at A1:A155
    the result at B1:B155
    the first formula at B1 (array formula)
    {="protocol "&TEXT(SMALL(--SUBSTITUTE($A$1:$A$155;"protocol";"");ROW(1:1));"00")}
    copy down

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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