+ Reply to Thread
Results 1 to 11 of 11

How to order a column ignoring the hyphens

  1. #1
    Registered User
    Join Date
    12-20-2008
    Location
    london
    Posts
    9

    How to order a column ignoring the hyphens

    Hi all,
    I have a column that orders fine a-z except for the fact that it doesn't group words together with hyphens e.g.:
    1.my-flies
    2.myflies
    3.my-fly
    4.myfly

    when I want it to be
    1.my-flies
    2.my-fly
    3.myfly
    4.myflies

    how can I do that please? Thanks and happy xmas

  2. #2
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    Does this work for you? Use a helper column, then sort by column B, then A

    =IF(ISERROR(IF(SEARCH("-",A1),0,1)),1,0)
    oldchippy
    -------------


    Blessed are those who can give without remembering and take without forgetting

    If you are happy with the help you have received, please click the <--- STAR icon on the left - Thanks.

    Click here >>> Top Excel links for beginners to Experts

    Forum Rules >>>Please don't forget to read these

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    You can use a helper column with the formula =substitute(A1, "-", "") and sort by that.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097
    shg - Nice one!

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Excel sorting ignores apostrophes (') and hyphens (-)

    Excel sorting ignores apostrophes (') and hyphens (-).
    http://support.microsoft.com/kb/322067

    You could try replacing all hyphens with another character...perhaps a pipe ( | )....sort....then replace the pipes with hyphens.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    WTY, OC. Merry Christmas.

  7. #7
    Registered User
    Join Date
    12-20-2008
    Location
    london
    Posts
    9

    Post

    Thank you for the replies really appreciated. What I have done is a combination of shg and ron's posts. I made another column and put =SUBSTITUTE(A1, "-", "|") getting rid of the hyphens and then sorted which is fine. What I need to do know now is how to replace the pipes with hyphens. Would I do this on another column? It seems a bit unwieldy to have my initial column then another one substituting the hyphens with pipes and then another one substituting the pipes with hyphens-am I missing something here should there only be one column? Thank you

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    How to order a column ignoring the hyphens

    Since you're using formulas....After you sort on the formula column,
    won't you still have the original column?

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    ???

    If you have a column with hyphens, and you have another column where the hyphen are replaced with pipes, why would you need yet another column to replace the pipes with hyphens -- that's what's in the original column.

  10. #10
    Registered User
    Join Date
    12-20-2008
    Location
    london
    Posts
    9
    Thanks yes you are right sorry it all got a bit confusing. It is now sorted fine, if i sort on the new column the original column now orders fine. I have to keep in that helper column to be able to sort it correctly I understand now, cheers guys!

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    If you're a happy camper, would you please mark the thread as Solved.

    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the words No prefix.
    Change to Solved
    Click Save

+ 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