Home > String Operations, Useful Procedures > A function to reverse a string

A function to reverse a string

August 16th, 2007 Leave a comment Go to comments

Very simple, uses the VBA function StrReverse to reverse the input string.

‘A function to reverse a string provided as input
‘For example, the string “abcd” will become “dcba”
‘Uses the VBA function StrReverse
Public Function ReverseString(sInputString As String) As String
On Error GoTo ReverseString_Error
    
ReverseString = StrReverse(sInputString)
    Exit Function

ReverseString_Error:
    ReverseString = “#ERROR#”
End Function

  1. nkarthick
    February 13th, 2008 at 07:42 | #1

    Hi
    Simple and superb code
    Please do visit my VBA blog
    http://chennaivba.blogspot.com
    and give me your thought.
    Thanks

  1. No trackbacks yet.