Reverse a String in VBA

To reverse a string in VBA, there's no need to try to do it manually using a loop because a function already exists for this!

Use the StrReverse function.

Use:

StrReverse(string)


Example

Reverse a first name using the StrReverse function:

Sub reverse()

    first_name = "John" 'Value: John
   
    result = StrReverse(first_name) 'Value: nhoJ
       
End Sub