# Reverse numbers and text

#### uttamsaxena

##### Board Regular
How can I reverse ------

1) A number e.g. 12345 to 54321

2) A word e.g uttamsaxena to anexasmattu

3) Small sentence like "This is cat" to "tac si siht"

### Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

#### Brian from Maui

##### MrExcel MVP
uttamsaxena said:
How can I reverse ------

1) A number e.g. 12345 to 54321

2) A word e.g uttamsaxena to anexasmattu

3) Small sentence like "This is cat" to "tac si siht"

Try ASAP Utilites under TEXT/Reverse text in selected cells.

www.asap-utilites.com

#### tusharm

##### MrExcel MVP
If you have Laurent Longre's outstanding -- and free -- MoreFunc utility (http://longre.free.fr/english/), you can use array formula =MCONCAT(MID(C4,LEN(C4)+1-ROW(INDIRECT("1:"&LEN(C4))),1)) where C4 contains the cell to reverse.

An array formula is completed not with the ENTER key but with CTRL+SHIFT+ENTER.

##### MrExcel MVP
=TEXTREVERSE(A1)

A function from the morefunc.xll add-in.

#### Todd Bardoni

##### Well-known Member

I wrote this function:

Code:
``````Function ReverseTxt(ByVal Target As Range)
myLength = Len(Target.Value)
For x = 0 To myLength
ReverseTxt = Left(WorksheetFunction.Substitute(Target.Value, Left(Target.Value, x), ""), 1) & ReverseTxt
Next x
End Function``````

It seems to work.

#### tusharm

##### MrExcel MVP
Interesting...it doesn't appear in my version of Morefunc. I guess I must have a old version of the add-in.
=TEXTREVERSE(A1)

A function from the morefunc.xll add-in.

#### tusharm

##### MrExcel MVP

If you must write a VBA function, just use VBA's Reverse() function!

Or if you are coding for VB5, use a loop for i=len(aStr) to 1 step -1 and Mid(aStr,i,1) to extract and concatenate each character. No need for calls on Left(...Substitute(...Left())).
tbardoni said:
I wrote this function:

Code:
``````Function ReverseTxt(ByVal Target As Range)
myLength = Len(Target.Value)
For x = 0 To myLength
ReverseTxt = Left(WorksheetFunction.Substitute(Target.Value, Left(Target.Value, x), ""), 1) & ReverseTxt
Next x
End Function``````

It seems to work.

#### Ekim

##### Well-known Member
The function from the morefunc add-in should be:
=REVERSETXT(A1)

not

=TEXTREVERSE(A1)

tbardoni,
It seems to work.
Worked for everything that I threw at it.

Just for interest, here’s another UDF from Otto Moehrbach:
Code:
``````Function MyStrReverse(s As String) As String
Dim i As Long, rslt As String
For i = Len(s) To 1 Step -1
rslt = rslt & Mid(s, i, 1)
Next i
MyStrReverse = rslt
End Function``````
Regards,

Mike

#### Todd Bardoni

##### Well-known Member
Ha! You're right, this is a little better
Code:
``````Function ReverseTxt(ByVal Target As Range)
ReverseTxt = StrReverse(Target.Value)
End Function``````

##### MrExcel MVP
Ekim said:
The function from the morefunc add-in should be:
=REVERSETXT(A1)

not

=TEXTREVERSE(A1)

Really? You must have a different version:
Book5
ABCD
11234554321
2
Sheet1

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,168,037
Messages
5,856,962
Members
431,841
Latest member
jaybeem

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

### Which adblocker are you using?

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

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