Thanks:  0
Likes:  0

# Thread: Reversing contents of a cell

1. 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

{=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.

3. 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

4. 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

5. 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/viewtop...c=4572&forum=2

or you could just look up "StrReverse" in VBA help, it's up to you. Y'know, whatever.

6. 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...

7. 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/viewtop...c=4572&forum=2

or you could just look up "StrReverse" in VBA help, it's up to you. Y'know, whatever. [img]/board/images/smiles/icon_smile.gif[/img]
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

8. Yeah, it's a new function from XL2000 onwards.

Nice bit of code from y'self though.

## User Tag List

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•