Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Nov 2001
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Convert a string (Excel XP)

    I need to change the direction of the letters in a string from left-to-right to right-to-left. For instance, if I have a string in A1 like "abcdef", I would like to be able to convert it to "fedcba" in B1 (without the quotation marks).
    The string might be of variable length and it might contain a space within it. If there are spaces at the beginning/end of the string, they can be trimmed.
    Is it possible to create a user defined function that will perform this task?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Convert a string (Excel XP)

    The followinfg User Defined function should do :<pre>
    Function Reverse(strInput As String) As String
    Reverse = StrReverse(strInput)
    End Function</pre>


    use

    =Reverse(A1) to reverse the contents of A1

    or

    to reverse and remove blanks use

    =SUBSTITUTE(Reverse(A1)," ","")

    Andrew C

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert a string (Excel XP)

    Thanks to your answer I found how to do it under Excel 97 too, at the following site:

    http://www.bris.ac.uk/is/selfhelp/document...1/exlvba-t1.pdf

    May thanks,
    Avi R

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Convert a string (Excel XP)

    You could have found it here in the forum in This Post also.
    Legare Coleman

Posting Permissions

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