View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Moset
 
Posts: n/a
Default How do I invert text (abc--cba)

Thanks, but I figured out another way that works better for what I'm trying
to accomplish. I should have stated in my original post, I wanted to invert
numbers, not actually text, but I thought text might be easier, then I could
multiply the "text" by 1 to change it to a number. Here's my solution using
VB:


===================================
Function invert(num)

If Len(num) = 1 Then invert = num Else:
If Len(num) = 2 Then invert = (Mid(num, 2, 1) & Mid(num, 1, 1)) Else:
If Len(num) = 3 Then invert = (Mid(num, 3, 1) & Mid(num, 2, 1) & Mid(num, 1,
1)) Else:
......
End Function
===================================

I could only get it to work for 55 characters because VB editor couldn't
handle a line of code any longer.


If you're curious, I was trying to solve a math problem that states, if you
incrementally add the inverse of a number to the previous total, how many
times do you have to get that before the result is an anagram. For instance:

6
6+6=12
12+21=33 (Two iterations)

(does it show how much of a Geek I am that this is what I'm doing for fun on
a Sat night?)



"Gilles Desjardins" wrote:

Yes use Data, text to column ( with your example will create a b c one
letter in each cell) then in a fourth one concatenate in reverse order.
HTH

Gilles
"Moset" wrote in message
...
Is there a simple formula in Excel to invert text?