+ Reply to Thread
Results 1 to 13 of 13

Custom sort depending on specific letters

  1. #1
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Custom sort depending on specific letters

    Hello everyone
    With new issue ..I hope it will be clear
    I have letters (not all letters) ordered in custom order in range(A4:A11) ..which we would depend on it in the process of sort
    In other words , the first letter in this list would have the priority in sort .. the first letter for example is letter "D" so all names which starts with "D" would be first and sorted of course
    and so on with other letter existed in the range

    As for the rest of names which are not included in the list of letters would be sorted in normal way
    Generally the desired results in the attachment will clarify my issue better
    Thanks advanced
    Attached Files Attached Files
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Custom sort depending on specific letters

    You have posted this in the VBA forum, and many of your previous project have preferred a VBA solution. How much of this must be done by VBA, and how much will you tolerate done by worksheet formulas and the built in Sort utility?

    The approach I would probably use for something like this would use minimal VBA and would look something like this.
    1) Make the list of "out of order" letters into a lookup table
    Please Login or Register  to view this content.
    2) Use a lookup function to add a column to the list to be sorted. Something like =iferror(vlookup(left(C1,$A$4:$B$11,2,false),9).
    3) Use the regular sort command to sort the list.
    a) sort first by the helper column created in 2 (maybe column D)
    b) then sort by the existing list column C.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Custom sort depending on specific letters

    Thanks a lot MrShorty for all your great help
    I liked a lot your simple and effective approach it's very great
    I applied your approach and everything is ok
    But as you told I prefer VBA solutions ...and at the same time my original file is very complicated so I don't need to use helper columns at all ..
    In your approach I had to use two helper columns ..
    Generally it is very very great steps to solve the problem
    I may try to interpret it to VBA steps
    Thank you very much

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Custom sort depending on specific letters

    Maybe :

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: Custom sort depending on specific letters

    Hi, this worked for me. The code also sorts the names within the chosen letters. It might need some optimization... Hope it helps!
    Attached Files Attached Files
    excelbat.com: free Excel tools, macros...

  6. #6
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Custom sort depending on specific letters

    Mr. Karedog
    Thanks a lot for all great and awesome gifts ..it works very well with the sample file (which was in English letters) ..
    I applied it to my original file in Arabic example I encountered an error
    Thanks a lot for help
    Attached Files Attached Files
    Last edited by YasserKhalil; 12-02-2015 at 07:48 AM.

  7. #7
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Custom sort depending on specific letters

    Quote Originally Posted by excel_bat View Post
    Hi, this worked for me. The code also sorts the names within the chosen letters. It might need some optimization... Hope it helps!
    Thanks a lot for help
    as for results I found that "Amany" was replaced with Aaa ...

  8. #8
    Registered User
    Join Date
    11-18-2015
    Location
    Madrid
    MS-Off Ver
    2016
    Posts
    95

    Re: Custom sort depending on specific letters

    Yes! I was checking that the code was sorting well. Sorry about that!

    Thanks for the rep!

  9. #9
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Custom sort depending on specific letters

    @MrShorty
    When trying to apply your approach to my original Arabic file I found that "أ" and "إ" and "ا" are the same ...while I need to deal with them as different instances ..and this caused incorrect results
    Hope it is clear

  10. #10
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Custom sort depending on specific letters

    Sorry, forget to check empty member :

    Please Login or Register  to view this content.
    Thank you for the rep. points.

  11. #11
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Custom sort depending on specific letters

    -- Deleted --
    Last edited by karedog; 12-02-2015 at 08:36 AM. Reason: Double post, kind of sucuri thing ;)

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Custom sort depending on specific letters

    Now it is very very perfect
    Thank you very much for this excellent and genius solution
    Regards

  13. #13
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Custom sort depending on specific letters

    You are welcome, glad I can help.


    Regards

+ 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: 11
    Last Post: 12-14-2020, 09:46 AM
  2. Replies: 1
    Last Post: 08-27-2014, 11:05 AM
  3. How to Custom Sort specific Pivot Table.
    By Eros23 in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-30-2013, 04:56 PM
  4. [SOLVED] Custom Sort by specific value descending then by alphabet ascending.
    By msmithdynamicsgp in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2013, 02:21 AM
  5. Custom Sort based on specific text
    By JEIrwin in forum Excel General
    Replies: 0
    Last Post: 02-29-2012, 12:27 PM
  6. How to sort Single Letters before Double Letters
    By jabberdoo in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-09-2008, 12:18 PM
  7. How to sort a column depending on number of letters
    By julia81 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-16-2008, 03:38 PM

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