+ Reply to Thread
Results 1 to 16 of 16

how to get the correct sort order

  1. #1
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    how to get the correct sort order

    how to get the correct sort order. when i tried i get the erroneous one.pls see the attached
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    04-09-2013
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: how to get the correct sort order

    Hi,

    I used helper column. See the file.
    Attached Files Attached Files

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

    Re: how to get the correct sort order

    depends on how many vol you have as well
    this as a helper will allow you to sort from
    vol-1-1 up to
    vol-99-999
    =LEFT(B2,4)&TEXT(SUBSTITUTE(LEFT(B2,FIND("-",B2,6)-1),"VOL-",""),"00")&"-"&TEXT(MID(B2,FIND("-",B2,5)+1,10),"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

  4. #4
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: how to get the correct sort order

    If the VOL numbers increase into the double digits, the problem is compounded because computers sort values from left to right. That is why you will get 20 sorted before 3 and 30 before 4.

    To get around this, copy the original data into column B and use Text to columns on column B. Use - as the delimiter. Don't import VOL. Click Finish. Now, sort on column B and add column C as a second sort.

    This shows the results after adding volume numbers higher than 10 for demonstration purposes.

    A
    B
    C
    1
    original H1 H2
    2
    VOL-1-1
    1
    1
    3
    VOL-1-2
    1
    2
    4
    VOL-1-3
    1
    3
    5
    VOL-1-4
    1
    4
    6
    VOL-1-5
    1
    5
    7
    VOL-1-6
    1
    6
    8
    VOL-1-7
    1
    7
    9
    VOL-1-9
    1
    9
    10
    VOL-1-49
    1
    49
    11
    VOL-1-50
    1
    50
    12
    VOL-2-26 2
    26
    13
    VOL-11-1 11
    3
    14
    VOL-11-15
    11
    15
    15
    VOL-11-11 11
    30
    16
    VOL-20-18
    20
    18
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  5. #5
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    Quote Originally Posted by martindwilson View Post
    depends on how many vol you have as well
    this as a helper will allow you to sort from
    vol-1-1 up to
    vol-99-999
    =LEFT(B2,4)&TEXT(SUBSTITUTE(LEFT(B2,FIND("-",B2,6)-1),"VOL-",""),"00")&"-"&TEXT(MID(B2,FIND("-",B2,5)+1,10),"000")
    thanks for the formula. but one querry. my original data is in col-A.even though i have changed all B2 in your formula to A2 nothing new happened.

  6. #6
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    Quote Originally Posted by misrasomendra View Post
    Hi,

    I used helper column. See the file.
    thanks for the direction. need somemore explanation. i checked with your formula. i get only the numbers minus the vol number.

  7. #7
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    Quote Originally Posted by newdoverman View Post
    If the VOL numbers increase into the double digits, the problem is compounded because computers sort values from left to right. That is why you will get 20 sorted before 3 and 30 before 4.

    To get around this, copy the original data into column B and use Text to columns on column B. Use - as the delimiter. Don't import VOL. Click Finish. Now, sort on column B and add column C as a second sort.

    This shows the results after adding volume numbers higher than 10 for demonstration purposes.

    A
    B
    C
    1
    original H1 H2
    2
    VOL-1-1
    1
    1
    3
    VOL-1-2
    1
    2
    4
    VOL-1-3
    1
    3
    5
    VOL-1-4
    1
    4
    6
    VOL-1-5
    1
    5
    7
    VOL-1-6
    1
    6
    8
    VOL-1-7
    1
    7
    9
    VOL-1-9
    1
    9
    10
    VOL-1-49
    1
    49
    11
    VOL-1-50
    1
    50
    12
    VOL-2-26 2
    26
    13
    VOL-11-1 11
    3
    14
    VOL-11-15
    11
    15
    15
    VOL-11-11 11
    30
    16
    VOL-20-18
    20
    18
    thanks for the suggestion.(see my post.it is vol number along with the track numbers) what you suggest is that we can not put vol number along with the tracknumbers?need to put in different columns?

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

    Re: how to get the correct sort order

    here it is in your workbook
    you need to use the helper column to sort by
    select columns a:b sort by column b
    Attached Files Attached Files

  9. #9
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: how to get the correct sort order

    Quote Originally Posted by sumesh56 View Post
    what you suggest is that we can not put vol number along with the tracknumbers?need to put in different columns?
    I'm not at all suggesting that you can't have your data as you do but if entered into different columns you don't have to rely on formulae to manipulate your data entry so that it can be sorted into the order that you want. How you enter your data will determine how you must process it in order to get what you want out of it.

    martindwilson has provided you an efficient formula that will give you a sortable version of your data in a helper column (msg #8)

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,736

    Re: how to get the correct sort order

    This formula array entered with Ctrl + Shift + Enter in B2 and then copied down should take care of the data supplied and accommodate any VOL-1 or VOL-10 or VOL-whatever.

    Then use as sort column as misrasomendra has done. (Workbook Post #2)

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Hope this helps.
    Last edited by FlameRetired; 10-27-2014 at 01:09 AM. Reason: clarified

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

    Re: how to get the correct sort order

    @ FlameRetired how would that sort this ?
    VOL-2-1
    VOL-1-1
    VOL-33-11
    VOL-4-11

  12. #12
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    Quote Originally Posted by martindwilson View Post
    here it is in your workbook
    you need to use the helper column to sort by
    select columns a:b sort by column b
    thanks for the reply. so this is a two step solution. am i right?assume that the data is in col A. first put the formula in col B and draw downwards.then select both col a and b and sort on col B. done.

  13. #13
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    thanks newdoverman for the suggestion and explanation.have a nice day.

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: how to get the correct sort order

    Thank you for the feedback.

    Have a nice day too.

  15. #15
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,736

    Re: how to get the correct sort order

    Quote Originally Posted by martindwilson View Post
    @ FlameRetired how would that sort this ?
    VOL-2-1
    VOL-1-1
    VOL-33-11
    VOL-4-11
    Hmmm. Good question since mine only sorts on the last group of digits!!

  16. #16
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2019
    Posts
    545

    Re: how to get the correct sort order

    Quote Originally Posted by martindwilson View Post
    here it is in your workbook
    you need to use the helper column to sort by
    select columns a:b sort by column b
    thanks a lot for the suggestion.it serves my purpose.your way of explanation is very simple.so nice of you to use that excel sheet to explain. have a nice day.
    Last edited by sumesh56; 10-30-2014 at 11:02 AM.

+ 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. Replies: 4
    Last Post: 11-20-2012, 06:00 PM
  2. Displaying data in the correct order???
    By Rhett19 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2011, 01:53 PM
  3. Ranking in correct order
    By bluejie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-22-2008, 03:14 PM
  4. Date info not in correct order
    By cfitzsimmons in forum Excel General
    Replies: 5
    Last Post: 06-11-2007, 01:20 PM
  5. [SOLVED] Pls. reply Sort Data and copy to next coulmn when sort order chang
    By shital shah in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-19-2005, 10:05 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