Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
CeeGee
 
Posts: n/a
Default 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   Report Post  
Gord Dibben
 
Posts: n/a
Default

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 InsertModule. 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
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   Report Post  
CeeGee
 
Posts: n/a
Default

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 InsertModule. 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
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   Report Post  
Gord Dibben
 
Posts: n/a
Default

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
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 InsertModule. 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
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   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7
Default How to Reverse Contents in an Excel cell (Text or a Number)

Ok, followed this in an Excel2003 workbook, and got ALMOST there. I was able
to get the reverse returned, but then adding the *1 returned a #VALUE! error.
Clicking the error tab did not give me the option to Convert To Number,
either.
If its any help, this is what I want to accomplish:
start with a number:
(ABC)
add its reverse (here is where I need the function)
ABC+CBA = XYZ
So:
A1 is (ABC)
B1 is (CBA)
C1 is A2 + B2 [XYZ]

THEN -
A2 = (XYZ)
B2 = (ZYX)

etc.

Any suggestions?


"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 InsertModule. 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
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





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default How to Reverse Contents in an Excel cell (Text or a Number)

My attempt at deciphering...........your use of text instead of numerics in your
example adds difficulty.

I will assume ABC, CBA and XYZ are numbers. If they are not then why would you
attempt to use the "+" sign?

A1 contains 987

B1 contains =revstr(A1)*1..............789

C1 contains =A1+B1.................1776

A2 contains =C1..................1776

B2 contains =revstr(C1)*1...............6771

"etc." can lead anywhere.


Gord

On Thu, 13 Sep 2007 09:04:04 -0700, 3kings
wrote:

Ok, followed this in an Excel2003 workbook, and got ALMOST there. I was able
to get the reverse returned, but then adding the *1 returned a #VALUE! error.
Clicking the error tab did not give me the option to Convert To Number,
either.
If its any help, this is what I want to accomplish:
start with a number:
(ABC)
add its reverse (here is where I need the function)
ABC+CBA = XYZ
So:
A1 is (ABC)
B1 is (CBA)
C1 is A2 + B2 [XYZ]

THEN -
A2 = (XYZ)
B2 = (ZYX)

etc.

Any suggestions?


"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 InsertModule. 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
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
When printing using Excel the text does not fit in the cell MSUbully Excel Discussion (Misc queries) 2 March 25th 05 06:49 PM
How can I edit cell contents with a macro in Excel? NotAnExpert Excel Discussion (Misc queries) 1 March 23rd 05 01:17 AM
Can I use the contents of a cell to satisfy the result_vector arg. robh_2 Excel Worksheet Functions 3 February 24th 05 08:14 PM
How do I get Excel to automatically enter the contents of a cell . andyb66 Excel Discussion (Misc queries) 1 January 22nd 05 08:04 AM
how to hyperlink text to a cell steve New Users to Excel 1 December 14th 04 08:21 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"