Reversing contents of a cell

EconSean

Board Regular
Joined
Apr 21, 2002
Messages
129
Hello all,

I am trying to figure out a way to take the contents (character) of a cell (A1 below), and in the cell immediately next to it (B1 below), place the reversed contents of that cell.

For example,

A B
1 god dog
2 cats stac

Any thoughts would be greatly appreciated.

Regards,

Sean
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Download (and add-in) morefunc.zip at http://perso.wanadoo.fr/longre/excel/downloads/, and use the following array formula...

{=MCONCAT(MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1))}

Note: Array formulas must be entered using the Control+Shift+Enter key combination. The outermost braces, { }, are not entered by you -- they're supplied by Excel in recognition of a properly entered array formula.
 
Upvote 0
Try the following UDF:

'----------------
Function ReverseIt(MyCell)
Dim temp, x As Integer, CellLen As Integer

CellLen = Len(MyCell)
For x = CellLen To 1 Step -1
temp = temp & Mid(MyCell, x, 1)

Next x
ReverseIt = temp
End Function
'----------------

Called as

=ReverseIt(A1)

for example.

Bye,
Jay
 
Upvote 0
I think I came up with a method to do this in a cell...

=CONCATENATE(MID(C2,6,1), MID(C2,5,1), MID(C2,4,1), MID(C2,3,1), MID(C2,2,1), MID(C2,1,1))


Thanks for the other ideas.

Regards,

Sean
 
Upvote 0
On 2002-04-22 12:16, EconSean wrote:
I think I came up with a method to do this in a cell...

=CONCATENATE(MID(C2,6,1), MID(C2,5,1), MID(C2,4,1), MID(C2,3,1), MID(C2,2,1), MID(C2,1,1))


Thanks for the other ideas.

Regards,

Sean

That will work, but only if you know the length of the string to be reversed beforehand. Best to use the LEN function to determine how many characters you're dealing with, then set up a loop to construct a new string using the MID function that loops thru the LENgth backwards (step -1). An example was posted above... but there's always more than one way to relieve a feline of their integuement... :)
 
Upvote 0
On 2002-04-22 12:21, Mark O'Brien wrote:
Jay,

have a look at the magnificent use of the "StrReverse" function posted by a gosh darned good looking fellow.

http://www.mrexcel.com/board/viewtopic.php?topic=4572&forum=2

or you could just look up "StrReverse" in VBA help, it's up to you. Y'know, whatever. /board/images/smiles/icon_smile.gif

Hi Mark,

Is StrReverse a new feature? I don't have it on my system. Excel97, NT4.0. Anyway, I just saw your thread, and that would be much more efficient. Nice job.

Also, you are very good with naming conventions for your variables. I have to get into that good habit.

Bye,
Jay
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,016
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top