Formula for reversing numbers or text?

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,222
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Guys

If i have a number like this 1234567 and i would like to reverse them so they go in this order 7654321. What is the formula to do this and for text also. i.e A B C D E (TO) E D C B A?

AND Also say i also wanted a formula to reverse but not include the 0 at the end i.e if i had 1234567000 i want it to return 7654321 not the 0.

Thank You
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
If you want it in one cell, use the following UDF:
Code:
Function Reverseit(r As String)
Dim s As String
s = StrReverse(r)
If IsNumeric(s) Then
    Reverseit = Val(s)
Else
    Reverseit = s
End If
End Function

Excel Workbook
AB
112345670007654321
2abcdefggfedcba
Sheet1
 

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,222
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
If you want it in one cell, use the following UDF:
Code:
Function Reverseit(r As String)
Dim s As String
s = StrReverse(r)
If IsNumeric(s) Then
    Reverseit = Val(s)
Else
    Reverseit = s
End If
End Function

Excel Workbook
AB
112345670007654321
2abcdefggfedcba
Sheet1



Thank You

Is there a formula approach?
 

justanotheruser

Board Regular
Joined
Aug 14, 2010
Messages
96
Hi.

I think that you need to create a function on VBA using the code that HOTPEPPER has supplied:

<CODE>Function Reverseit(r As String)
Dim s As String
s = StrReverse(r)
If IsNumeric(s) Then
Reverseit = Val(s)
Else
Reverseit = s
End If
End Function</CODE>

Then you can use the formulas as he (?) stated, and I presume that it should work.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,944
Office Version
  1. 365
Platform
  1. Windows
A UDF is a formula approach, if you mean by only using the standard formula functions then I don't think it's possible, the only alternative I can think of is with the use of MCONCAT, which requires the installation of Morefunc.
 

T. Valko

Well-known Member
Joined
May 9, 2009
Messages
16,623
Here's a formula that uses worksheet functions that will reverse a numeric string.

A1 = some number like 1234567000

=--TEXT(SUMPRODUCT(MID(A1,ROW(INDIRECT("1:" & LEN(A1))),1)*10^(ROW(INDIRECT("1:" & LEN(A1)))-1)),REPT("0",LEN(A1)))

Result = 7654321

I don't know of a technique using worksheet functions that'll reverse a text string.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,719
Messages
5,597,733
Members
414,170
Latest member
Mdm

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Top