reverse & inverse text: pot ot mottob morf...esrever ot detr

techsuccess

New Member
Joined
Apr 8, 2002
Messages
1
A colleague has started sending mail to me in this format and I would like to be able to return the favor without asking his secret. How do I reverse & invert text as shown below:

pot ot mottob morf...esrever ot detrevnoc uoy woh tuo erugif t'nac I
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Something like this would do it:

<pre>
Public Sub InvertText()

Dim sText As String
Dim sInvertedText As String

sInvertedText = "pot ot mottob morf...esrever ot detrevnoc uoy woh tuo erugif t'nac I"
sText = StrReverse(sInvertedText)

MsgBox sText

End Sub</pre>

HTH
 
Upvote 0
This is the function which would do that:

Function Reversed(originaltext As String) As String
Dim i As Integer
For i = Len(originaltext) To 1 Step -1
Reversed = Reversed & Mid(originaltext, i, 1)
Next i
End Function


If you want to use this function in excel (we are in MrExcel :))) then you can apply it as below:

Open VBE and insert a module in related VBA project. Paste the code above.
Goto excel sheet and write something reversed A1 and put this function into A2.

=REVERSED(A1)

you will see the re-reversed text in A2.

Regards
 
Upvote 0
Download (and add-in) morefunc.zip at http://perso.wanadoo.fr/longre/excel/downloads/, and use the following array formula...

{=MCONCAT(MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1))}

Note: Array formulas must be entered using the Control+Shift+Enter key combination. The outermost braces, { }, are not entered by you -- they're supplied by Excel in recognition of a properly entered array formula.
 
Upvote 0
How about the following code:<PRE>Sub ReverseWords()
Dim WorkingText as string, ReversedText As String
Dim PrevSpace as integer, NextSpace As Integer
OriginalText = InputBox("Enter text to be reversed word by word")
WorkingText = " " & Replace(OriginalText, " ", " ") & " "
Do
PrevSpace = Application.WorksheetFunction.Search(" ", WorkingText, PrevSpace + 1)
NextSpace = Application.WorksheetFunction.Search(" ", WorkingText, PrevSpace + 1)
ReversedText = ReversedText + StrReverse(Mid(WorkingText, PrevSpace + 1, NextSpace - PrevSpace))
Loop Until NextSpace = Len(WorkingText)
MsgBox ReversedText
End Sub</PRE>

It will reverse the text word by word.

_________________
Kind regards,<font size="5"><sup><span style="text-decoration: overline">AL</span></sup><u><sub>CHARA</sub></u></font
This message was edited by Al Chara on 2002-07-31 08:51
This message was edited by Al Chara on 2002-07-31 08:54
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,533
Members
448,969
Latest member
mirek8991

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