Consulting

Results 1 to 7 of 7

Thread: VBA Help to Reverse a String without StrReverse function

  1. #1
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location

    Thumbs up VBA Help to Reverse a String without StrReverse function

    Hi Team, 
    
    
    Need your help  to reverse the string in Column A and paste in Column B. 
    Through loop and without using STRREVERSE function. Sample Data as shown below
    
    
    • Column A
    • Column B
    • string
    • Result
    • sdfasf
    • fsafds
    • uios
    • soiu
    • kdsljf23
    • 32fjlsdk
    :think: Thanks in advance Regards, Mallesh

  2. #2
    Try this UDF
    Function strReverse(ByVal cell As Range) As String    strReverse = VBA.strReverse(cell.Value)
    End Function

  3. #3
    VBAX Regular pike's Avatar
    Joined
    Dec 2007
    Location
    Alstonville, Australia
    Posts
    97
    Location
    Hello malleshg2,
    Excel 2016 array formula
    =IF(A1="","",CONCAT(MID(A1,1 + LEN(A1)-ROW(INDIRECT("1:" & LEN(A1))),1)))

  4. #4
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location
    Hi Khalil and Pike

    Thanks a lot both of you,
    one of my friend challenged me to reverse the string, without using STRReverse function in VBA.
    Is it possible i am new in coding. Thanks

    Regards
    Mallesh

  5. #5
    Hello ..
    No problem. There must be always another way
    Try this
    Sub Test_ReverseString_UDF()
        MsgBox ReverseString("Hello World")
    End Sub
    
    
    Function ReverseString(s As String)
        Dim t As String
        Dim n As Long
        
        For n = Len(s) To 1 Step -1
            t = t & Mid(s, n, 1)
        Next n
        
        ReverseString = t
    End Function

  6. #6
    Banned VBAX Contributor
    Joined
    Aug 2017
    Posts
    144
    Location
    Superb !

    Thank you so much Khalil and Poke for lovely solution.

    Regards,
    Mallesh

  7. #7
    You're welcome. Glad we can offer some help

Posting Permissions

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