+ Reply to Thread
Results 1 to 13 of 13

reverse letter sorting in a cell

  1. #1
    Registered User
    Join Date
    06-20-2009
    Location
    Belgrade, Serbia
    MS-Off Ver
    Excel 2007
    Posts
    35

    reverse letter sorting in a cell

    I have specific need for text manipulating formula. Is it possible to reverse text in a cell, for example: microsoft excel to lecxe tfosorcim.
    Thanks in advance...
    Last edited by sakinen; 06-21-2009 at 02:48 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: reverse letter sorting in a cell

    Hi Sakinen. Welcome to the Forum. Here's a new Function you can add to your worksheet to give yourself this simple functionality:

    Please Login or Register  to view this content.
    (Install that in a standard module) (source)

    Then just use it like so...to reverse the text in A1, put this in B1:
    =REVERSE(A1)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: reverse letter sorting in a cell

    sakinen,

    If cell A1 contains:
    microsoft excel

    The formula/function in cell B1:
    =ReverseCell(A1,TRUE)

    returns:
    lecxe tfosorcim



    Please TEST this FIRST in a COPY of your workbook (always make a backup copy before trying new code, you never know what you might lose).

    Adding the Macro
    1. Copy the below macro, by highlighting the macro code and pressing the keys CTRL+C
    2. Open your workbook
    3. Press the keys ALT+F11 to open the Visual Basic Editor
    4. Press the keys ALT+I to activate the Insert menu
    5. Press M to insert a Standard Module
    6. Paste the code by pressing the keys CTRL+V
    7. Press the keys ALT+Q to exit the Editor, and return to Excel.

    Please Login or Register  to view this content.
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: reverse letter sorting in a cell

    Hello sakinen,

    Since Excel 2000, there has been a built in function to do this StrReverse.

    Example
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: reverse letter sorting in a cell

    Oh my, Leith! Great stuff. That makes a custom function ONE LINE long...hehe. Seems to work equally well for text and numerics..
    Please Login or Register  to view this content.
    =REVERSE(A1)

    This does convert numeric values INTO strings, but if you know you're dealing with numbers, that's easy to fix, too:

    =REVERSE(A1)+0
    Last edited by JBeaucaire; 06-20-2009 at 06:08 PM.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: reverse letter sorting in a cell

    I guess it's simple enough to build the "is it a number" test into the function:
    Please Login or Register  to view this content.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: reverse letter sorting in a cell

    With this function, Reverse("100") = Reverse("10")

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: reverse letter sorting in a cell

    Hmm, that does open a whole can of worms. Anything I do to lead a numeric with zeros effectively converts the string BACK into text when I feed it back to the formula. SO...

    Leaving the function in it's simpler form (post #5) doesn't suffer from this problem UNLESS the user decides on their own to add back in +0. So, that's probably the simplest. The user is in control of the output appearance

    What do you think?

  9. #9
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: reverse letter sorting in a cell

    I think that Reverse is a string function that accepts a string as its argument. If Reverse(Number) doesn't return an error, Reverse(Number)=Number seems logical.
    Please Login or Register  to view this content.
    Last edited by mikerickson; 06-21-2009 at 12:28 AM.

  10. #10
    Registered User
    Join Date
    06-20-2009
    Location
    Belgrade, Serbia
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: reverse letter sorting in a cell

    Thanks a lot guys... I didn't expect this number of solutions. I will put them all to trial. Thanks again.

  11. #11
    Registered User
    Join Date
    06-20-2009
    Location
    Belgrade, Serbia
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: reverse letter sorting in a cell

    Just out of curiosity, is it possible to do the same thing on a selection...

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

    Re: reverse letter sorting in a cell

    For example, ...?
    Entia non sunt multiplicanda sine necessitate

  13. #13
    Registered User
    Join Date
    06-20-2009
    Location
    Belgrade, Serbia
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: reverse letter sorting in a cell

    For example i select the cells i want to reverse the letter order then press some kind of macro button, and the selected cells become reversed.

+ 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