Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 5 of 5

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

  1. #1
    New Member
    Join Date
    Apr 2002
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Something like this would do it:


    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


    HTH

  3. #3
    BatCoder
    Join Date
    Feb 2002
    Location
    Turkey
    Posts
    816
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    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




    Suat

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Austin, Texas USA
    Posts
    11,654
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  5. #5
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    How about the following code:
    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


    It will reverse the text word by word.

    _________________
    Kind regards,

    ALCHARA
    [ 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 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •