+ Reply to Thread
Results 1 to 5 of 5

How to Reverse Contents in an Excel cell (Text or a Number)

  1. #1
    CeeGee
    Guest

    How to Reverse Contents in an Excel cell (Text or a Number)

    If I have the following text string in a cell "abc123.xyz" how do I reverse
    the contents i.e. "zyx.321cba"?

    If the cell contains a numeric value e.g. 12345, then I want to know how to
    reverse it i.e. 54321

  2. #2
    Gord Dibben
    Guest

    Re: How to Reverse Contents in an Excel cell (Text or a Number)

    CeeGee

    By using a user defined function.

    Public Function RevStr(Rng As Range)
    RevStr = StrReverse(Rng.text)
    End Function

    Usage is: =RevStr(cellref)

    If the data is numeric...... =RevStr(cellref)*1 which forces it back to
    numeric.

    This function would be copied to a general module in your workbook.

    If not familiar with macros and VBA, visit David McRitchie's website on
    "getting started".

    http://www.mvps.org/dmcritchie/excel/getstarted.htm

    In the meantime..........

    To create a General Module, hit ALT + F11 to open the Visual Basic Editor.

    Hit CRTL + R to open Project Explorer.

    Find your workbook/project and select it.

    Right-click and Insert>Module. Paste the above code in there. Save the
    workbook and hit ALT + Q to return to your workbook.


    Gord Dibben Excel MVP

    On Fri, 20 May 2005 15:16:02 -0700, CeeGee <[email protected]>
    wrote:

    >If I have the following text string in a cell "abc123.xyz" how do I reverse
    >the contents i.e. "zyx.321cba"?
    >
    >If the cell contains a numeric value e.g. 12345, then I want to know how to
    >reverse it i.e. 54321



  3. #3
    CeeGee
    Guest

    Re: How to Reverse Contents in an Excel cell (Text or a Number)

    Thanks very much Gord, the solution you provided is very nifty. I have over
    30,000 rows of data which I can now apply this to.

    Maybe Microsoft will provide this as a standard function one day.

    Thanks again.

    "Gord Dibben" wrote:

    > CeeGee
    >
    > By using a user defined function.
    >
    > Public Function RevStr(Rng As Range)
    > RevStr = StrReverse(Rng.text)
    > End Function
    >
    > Usage is: =RevStr(cellref)
    >
    > If the data is numeric...... =RevStr(cellref)*1 which forces it back to
    > numeric.
    >
    > This function would be copied to a general module in your workbook.
    >
    > If not familiar with macros and VBA, visit David McRitchie's website on
    > "getting started".
    >
    > http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >
    > In the meantime..........
    >
    > To create a General Module, hit ALT + F11 to open the Visual Basic Editor.
    >
    > Hit CRTL + R to open Project Explorer.
    >
    > Find your workbook/project and select it.
    >
    > Right-click and Insert>Module. Paste the above code in there. Save the
    > workbook and hit ALT + Q to return to your workbook.
    >
    >
    > Gord Dibben Excel MVP
    >
    > On Fri, 20 May 2005 15:16:02 -0700, CeeGee <[email protected]>
    > wrote:
    >
    > >If I have the following text string in a cell "abc123.xyz" how do I reverse
    > >the contents i.e. "zyx.321cba"?
    > >
    > >If the cell contains a numeric value e.g. 12345, then I want to know how to
    > >reverse it i.e. 54321

    >
    >


  4. #4
    Gord Dibben
    Guest

    Re: How to Reverse Contents in an Excel cell (Text or a Number)

    Thanks for the feedback.

    Note that if your numerics end in zeros like 123400 the 00 will be dropped if
    you use the =RevStr(cellref)*1

    To keep the zeros you must change them to text per the =RevStr(cellref).


    Gord

    On Sat, 21 May 2005 04:07:01 -0700, CeeGee <[email protected]>
    wrote:

    >Thanks very much Gord, the solution you provided is very nifty. I have over
    >30,000 rows of data which I can now apply this to.
    >
    >Maybe Microsoft will provide this as a standard function one day.
    >
    >Thanks again.
    >
    >"Gord Dibben" wrote:
    >
    >> CeeGee
    >>
    >> By using a user defined function.
    >>
    >> Public Function RevStr(Rng As Range)
    >> RevStr = StrReverse(Rng.text)
    >> End Function
    >>
    >> Usage is: =RevStr(cellref)
    >>
    >> If the data is numeric...... =RevStr(cellref)*1 which forces it back to
    >> numeric.
    >>
    >> This function would be copied to a general module in your workbook.
    >>
    >> If not familiar with macros and VBA, visit David McRitchie's website on
    >> "getting started".
    >>
    >> http://www.mvps.org/dmcritchie/excel/getstarted.htm
    >>
    >> In the meantime..........
    >>
    >> To create a General Module, hit ALT + F11 to open the Visual Basic Editor.
    >>
    >> Hit CRTL + R to open Project Explorer.
    >>
    >> Find your workbook/project and select it.
    >>
    >> Right-click and Insert>Module. Paste the above code in there. Save the
    >> workbook and hit ALT + Q to return to your workbook.
    >>
    >>
    >> Gord Dibben Excel MVP
    >>
    >> On Fri, 20 May 2005 15:16:02 -0700, CeeGee <[email protected]>
    >> wrote:
    >>
    >> >If I have the following text string in a cell "abc123.xyz" how do I reverse
    >> >the contents i.e. "zyx.321cba"?
    >> >
    >> >If the cell contains a numeric value e.g. 12345, then I want to know how to
    >> >reverse it i.e. 54321

    >>
    >>



  5. #5
    Registered User
    Join Date
    07-24-2012
    Location
    Maryland
    MS-Off Ver
    Microsoft Office Small Business 2007
    Posts
    9

    Re: How to Reverse Contents in an Excel cell (Text or a Number)

    OMG!! Are you serious? I know how to take a VBA program an rewrite it or modify it, in fact I am very skilled. but your answer didn't even work. And this is important it's not even for work it is for my life. Can't you write something for the "rest of us"

+ 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