Thanks:  0
Likes:  0

# Thread: Reverse numbers and text

1. ## Reverse numbers and text

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"

2. ## Re: Reverse numbers and text

Originally Posted by uttamsaxena
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

3. ## Re: Reverse numbers and text

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.

4. ## Re: Reverse numbers and text

=TEXTREVERSE(A1)

A function from the morefunc.xll add-in.

5. ## Re: Reverse numbers and text

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.

6. ## Re: Reverse numbers and text

Interesting...it doesn't appear in my version of Morefunc. I guess I must have a old version of the add-in.
Originally Posted by Aladin Akyurek
=TEXTREVERSE(A1)

A function from the morefunc.xll add-in.

7. ## Re: Reverse numbers and text

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())).
Originally Posted by tbardoni
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.

8. ## Re: Reverse numbers and text

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

9. ## Re: Reverse numbers and text

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

10. ## Re: Reverse numbers and text

Originally Posted by Ekim
The function from the morefunc add-in should be:
=REVERSETXT(A1)

not

=TEXTREVERSE(A1)
Really? You must have a different version:

******** ******************** ************************************************************************>
 Microsoft Excel - Book5 ___Running: xl2000 : OS = Windows Windows 2000
 (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)bout
 B1 =

A
B
C
D
1
1234554321
2
 Sheet1

[HtmlMaker 2.32] To see the formula in the cells just click on the cells hyperlink or click the Name box
PLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

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