# [Solved] Formulas : Inverting number

• Do you know how to transpose the numbers within a cell, for example, cell A1 says 12345, I want cell B1 to say 54321. Is that possible?

• There is a utility called asap utilities, available free from
http://www.asap-utilities.com
One option on the text menu is to reverse text in selected cells. Works well.

Richard

If absence makes the heart grow fonder, and familiarity breeds contempt, perhaps my wife should live in Darwin?

• Dave sent me to a web site to get this formula.

How does it work?

Function ReverseCell(Rcell As Range, Optional IsText As Boolean)
Dim i As Integer
Dim StrNewNum As String
Dim strOld As String

strOld = Trim(Rcell)

For i = 1 To Len(strOld)
StrNewNum = Mid(strOld, i, 1) & StrNewNum
Next i

If IsText = False Then
ReverseCell = CLng(StrNewNum)
Else
ReverseCell = StrNewNum
End If
End Function

Using the loop (i = 1 to Len(stgOld)) starts it off. When the Mid function is used inside the loop causes each character to be used. What would happen if the Len was used? Only one character would be shown?

• Hi BearCub

Did it work for your data?

Len is used to return the number of characters in a String. This is what is used to determine how many loops to perform.

## Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!