reverse cell value

  • Thread starter Thread starter Frank
  • Start date Start date
F

Frank

How can I in excel reverse the contents of a cell??


Example
Before: 1101001
after : 1001011


Thanks,

Frank
 
Frank said:
How can I in excel reverse the contents of a cell??

Example
Before: 1101001
after : 1001011

Thanks,

Frank

Hi Frank,

=REVERSE(...) should work on strings.

HTH
@+
FxM
 
How is it used? Don't see it in the help section. =reverse(a2) doe
snot see to work get a #name?
 
Ouupps, sorry guys,

This function is included in an add-in : funcustomize (freeware)
http://longre.free.fr So easy to use that I forget the origin.

Should be something like the following perso function :
Public Function reverse(inp)
b = "": inp = CStr(inp)
For a = 1 To Len(inp)
b = b & Mid(inp, Len(inp) - a + 1, 1)
Next a
reverse = b
End Function

@+
FxM




FxM a écrit :
 
I'm not sure when strReverse was introduced, it is certainly in
Excel 2000, and I'm pretty sure it was not in Excel 95..

Function Reverse(cell As Range) As String
Reverse = strReverse(cell)
End Function

=Reverse(A2)
=personal.xls!Reverse(A2)

http://www.mvps.org/dmcritchie/excel/strings.htm
http://www.mvps.org/dmcritchie/excel/join.htm

I've only worked with it as Text cells, so I expect this
would work better for you I tested it on a numeric
zip code even though I normally have zip codes as text.
You will, of course, get text out of the function ("As String").

Function ReverseT(cell As Range) As String
ReverseT = strReverse(cell.Text)
End Function.
 
David McRitchie said:
I'm not sure when strReverse was introduced, it is certainly in
Excel 2000, and I'm pretty sure it was not in Excel 95..
....

It came with VBA 6 in XL2K.
Function Reverse(cell As Range) As String
Reverse = strReverse(cell)
End Function ....
Function ReverseT(cell As Range) As String
ReverseT = strReverse(cell.Text)
End Function.

Or don't assume the argument is always a range.

Function rev(v As Variant) As Variant
If TypeOf v Is Range Then
rev = StrReverse(v.Text)
Else
rev = StrReverse(v)
End If
End Function

If A1 contained 12345 formatted as 0.00000E+00, then rev(A1) would return
40+E05432.1 and rev(A1&"") would return 54321. Next obvious embellishment
(which I'm too lazy to add just now) would be the array capability.
 
Hi
if you follow the link you'll see a discussion just two
days ago in which esp. Harlan and Jerry provided some nice
solutions for your issue

As a small hint. I can recommend Ron's Google search add-
in to search the Google archives for this kind of common
questions. IMHO one of the best ways as most of the
questions have been covered several times before. See
http://www.rondebruin.nl/Google.htm
 
Frank

FWIW here's a formula solution. It can only be used
on integers without a trailing zero. (8765601 is OK,
876560 is not). If your numbers always has the same
number of digits, e.g. 8, you can make a workaround
by formatting the cell with the custom number format 00000000
Of course you can also use this formatting with a varying
number of digits in the number, but it may be too cumbersome
to change the format all the time :-)

=SUMPRODUCT(10^(LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1)))-1),
MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1)+0)
 
Back
Top