Formula for reversing numbers or text?

mahmed1

Well-known Member
Joined
Mar 28, 2009
Messages
2,302
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
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,039
Members
449,063
Latest member
ak94

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
Back
Top