+ Reply to Thread
Results 1 to 12 of 12

sort characters within a cell

  1. #1
    Registered User
    Join Date
    07-30-2015
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    6

    sort characters within a cell

    Hi all, I need help here - I have a column of characters in each cell.

    e.g.

    A1
    qwerty
    asdfgh
    zxcvbn

    What I need is to sort the characters within the cell alphabetically, i.e. the result should be:

    A1
    eqrtwy
    adfghs
    bcnvxz

    any way to do this? much appreciated, thank you!

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    Are they always the same length?

  3. #3
    Registered User
    Join Date
    07-30-2015
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    6

    Re: sort characters within a cell

    no, differing lengths

  4. #4
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    Doing it via VBA would be your best option. Doing it with formulas is quite tedious. Would that suit you?

    Also, should capital letters be sorted accordingly also?

    I.e. should aBCdEf be
    1) aBCdEf; or
    2) BCEadf; or
    3) adfBCE

  5. #5
    Registered User
    Join Date
    07-30-2015
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    6

    Re: sort characters within a cell

    thanks for your reply!

    captial letters should be sorted accordingly, so it should be 1) aBCdEf

  6. #6
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    Write the following code into a module within VBA.

    Then in Excel, say A1 has qwerty, type in any other cell =SortLetters(A1)

    Edit: See below.
    Last edited by quekbc; 07-31-2015 at 12:52 AM.

  7. #7
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: sort characters within a cell

    I get an error in your code with lLength.

    It looks like you try to redim it before it has a value. Care to test your code before posting it for us guys who try to use it?
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  8. #8
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    My bad. I did test it. Then I pasted it over. Not sure what happened there. I must've accidentally moved it.

    Please Login or Register  to view this content.
    As a side note, whilst I appreciate any criticism that you may have, I do not appreciate the implication that I did not test my solutions before pasting it here. Sure that may happen for a simple solution but my brain is far from being able to write the above directly here and have it working at first go.

  9. #9
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: sort characters within a cell

    I was very excited and interested in how you did this problem. Then I pasted your code in a module and was disappointed it gave an error, instead of working. Sorry if I was a little short as I was really wanting it to work.

  10. #10
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    Not a problem, Marvin. It should be working now.

  11. #11
    Registered User
    Join Date
    07-30-2015
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    6

    Re: sort characters within a cell

    thank you so much quekbc for your help. it works fine for me.

  12. #12
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: sort characters within a cell

    Excellent. That's good to hear. If this resolves your question, please mark the thread as Solved by clicking Thread Tools above your first post, and select "Mark your thread as Solved".

+ 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. [SOLVED] Adjust Code to Sort by specific Cell characters found with cell
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-15-2014, 02:34 PM
  2. Sort by number of characters in cell/column? How please?
    By be-nice-2-me in forum Excel General
    Replies: 3
    Last Post: 06-25-2013, 08:09 AM
  3. Sort on accented (French) characters
    By greek in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-30-2011, 06:43 AM
  4. Sort by number of characters?
    By DrSues02 in forum Excel General
    Replies: 5
    Last Post: 01-16-2011, 04:21 PM
  5. Replies: 3
    Last Post: 12-10-2009, 09:30 PM
  6. How do I sort in Excel by the no. of characters in a cell?
    By yasmingeo in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-21-2005, 08:05 AM
  7. [SOLVED] I want to sort, ignoring all characters except numbers
    By wojo in forum Excel General
    Replies: 15
    Last Post: 07-08-2005, 05:05 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