+ Reply to Thread
Results 1 to 4 of 4

How do I sort so that 1.2 comes before 1.10, while taking triple digit into consideration?

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2003
    Posts
    3

    How do I sort so that 1.2 comes before 1.10, while taking triple digit into consideration?

    Hello,

    I have a very similar question to another post that was resolved. However, the answer they got almost works for what I need, it does not take triple digit decimals into consideration, or at least does not work for them. The original thread is here:

    http://www.excelforum.com/excel-gene...re-1-10-a.html

    There was a solution posted on that page, that is as follows. It suggested making a "fake column" which can later be removed, using formula:

    =--(LEFT(A1,SEARCH(".",A1))&RIGHT("0"&REPLACE(A1,1,SEARCH(".",A1),""),2))

    Which seems to work almost perfectly. That is, if my numbers were only single and double digits after the decimal. However, if the number has both a number with 2 place decimal (like 45.01) and triple place (like 45.101) the formula drops off the first one in the second number, thus turning them both into 45.01.

    I tried manipulating the code a bit to make that work, but it doesn't seem to put them in the right order, with the formula above, it seems to drop the first decimal digit, or I'm screwing it up. I cannot just leave things in the "correct" order, as another program I use reads these numbers. So I have to upload these files into the program in the order it accepts, which would really look like this (even though it's technically incorrect)

    1.1
    1.2
    1.9
    1.10
    1.11
    1.13
    1.110
    1.125
    1.126
    1.127
    etc.

    As the program itself only deals with the numbers in this format, and in this order. So right now I'm spending a bunch of time cutting and pasting the lines where they need to go. The formula above does sometimes help, but once i get a number with three digits after the decimal, every other number is in the incorrect order, so I have to do manually.

    Any help would be outstanding.

  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: How do I sort so that 1.2 comes before 1.10, while taking triple digit into considerat

    try
    =LEFT(A1,FIND(".",A1)-1)&"."&TEXT(MID(A1,FIND(".",A1)+1,3),"000")
    "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
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: How do I sort so that 1.2 comes before 1.10, while taking triple digit into considerat

    not sure if this will help or not, but give it a shot...

    =IF(LEN(A1)<=4,--(LEFT(A1,SEARCH(".",A1))&RIGHT("0"&REPLACE(A1,1,SEARCH(".",A1),""),2)),
    --(LEFT(A1,SEARCH(".",A1))&RIGHT("00"&REPLACE(A1,1,SEARCH(".",A1),""),4)))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    12-05-2012
    Location
    Baltimore, MD
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: How do I sort so that 1.2 comes before 1.10, while taking triple digit into considerat

    Quote Originally Posted by martindwilson View Post
    try
    =LEFT(A1,FIND(".",A1)-1)&"."&TEXT(MID(A1,FIND(".",A1)+1,3),"000")
    That did it! Geez, I wish I knew about this website earlier!

+ 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