reverse number order in a cell

rolson7560

New Member
Joined
Oct 14, 2009
Messages
4
I'd like to take the value from one cel, and reverse the digit order in another cell. Example cell c11 value is 1234, I want to display that value in cell c12 as 4321. Is there a way to do this?
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi, This will reverse cell values in a list in column "A" to column "B".
You could run it as a Function, Or use it for just one cell.
Code:
[COLOR=navy]Sub[/COLOR] MG14Oct34
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range
[COLOR=navy]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
    Dn.Next = StrReverse(Dn)
[COLOR=navy]Next[/COLOR] Dn
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 

SteveO59L

Well-known Member
Joined
Apr 21, 2004
Messages
7,896

ADVERTISEMENT

=(right(g18,1)&mid(g18,3,1)&mid(g18,2,1)&left(g18,1))*1
 

doofusboy

Well-known Member
Joined
Oct 14, 2003
Messages
1,325
Here's one way:

Code:
Dim iCTR As Integer
Dim x As Integer
 
    For iCTR = 1 To 5
        For x = Len(Range("A" & iCTR).Value) To 1 Step -1
            Range("B" & iCTR).Value = Range("B" & iCTR).Value & Mid(Range("A" & iCTR).Value, x, 1)
        Next x
    Next iCTR
 

rolson7560

New Member
Joined
Oct 14, 2009
Messages
4

ADVERTISEMENT

This is great!!! Thank you!!!
 

Colin Legg

MrExcel MVP, Like totally RAD man
Joined
Feb 28, 2008
Messages
3,497
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Another way:

Excel Workbook
AB
131200213
Sheet1

Excel 2002
Cell Formulas
RangeFormula
B1=REVERSE(A1)




Code:
Public Function REVERSE(ByVal rngSource As Range) As Variant
    REVERSE = StrReverse(rngSource.Value)
End Function
(no error handling included)
 

rolson7560

New Member
Joined
Oct 14, 2009
Messages
4
THANK YOU ALL!!! It's amazing how many different ways this can happen!
I learned a LOT!
 

Ron Coderre

MrExcel MVP
Joined
Jan 14, 2009
Messages
2,316
A bit late...but this formula reverses numbers of any length.
Code:
=MID(SUMPRODUCT(MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1),1)),1)*10^
(ROW($A$1:INDEX($A:$A,LEN(A1)))-LEN(A1)-1)),3,255)

I hope that helps.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,890
Messages
5,544,883
Members
410,643
Latest member
sng
Top