+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : Alphabetize 4 letters in a single cell formula

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

    Alphabetize 4 letters in a single cell formula

    I want to alphabetize a single cell sting like "HARD" to "ADHR" using a single cell formula. No VBA allowed.

    I could do it if
    Small({Code("H"),Code("A"),Code("R"),Code("D")},1)
    would do what I wanted.

    Any suggestions?

    See attached for Alphabetizing 3 letter strings works and how I get stuck.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: Alphabetize 4 letters in a single cell formula

    Not quite elegant but...
    Attached Files Attached Files

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Alphabetize 4 letters in a single cell formula

    Perhaps you mean:

    Please Login or Register  to view this content.
    working with strings / concatenating etc in array form is not quite as trivial / flexible as is the case with numbers (unavoidable repetition etc)

    edit:
    the above is similar in concept to zbor's except it uses explicit in line array which avoids need for array entry (given we are working explicitly with 4 chars)

    further late edit:
    it is assumed no VBA extends to 3rd party .xla's like morefunc which would permit use of MCONCAT
    Last edited by DonkeyOte; 03-06-2011 at 05:39 PM.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Alphabetize 4 letters in a single cell formula

    Rather than add yet further late edits...

    The point regards working with strings in this manner is that native CONCATENATE does not permit arrays (hence point re: MCONCAT).

    Actually creating an array of chars listed A-Z is relatively trivial:

    Please Login or Register  to view this content.
    (obviously use of {1;2;3;4} is for demo purposes - this can be variable per length of string)

    However, rather annoyingly there is no native function available that would permit you to re-join the items into a single string.

+ 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