Excel VBA StrReverse Function
The StrReverse function returns a String after reversing the given String.
Syntax
StrReverse (Expression)
Parameter
Expression (required) – This parameter represents the String that you want to reverse.
Return
This function returns a String after reversing the given String.
Example 1
Sub ReverseFunction_Example1()
' Reverse the String "HELLO VBA".
Dim revStr As String
revStr = StrReverse("HELLO VBA")
' The variable will return string "ABV OLLEH".
ActiveCell.Value = revStr
End Sub
Output
ABV OLLEH

Example 2
Sub ReverseFunction_Example2() ' Reverse the String "HELLO VBA". Dim revStr As String Dim str As String str = "MADAM" revStr = StrReverse(str) If str = revStr Then MsgBox (str + " is Palindrome") Else MsgBox (str + " is not Palindrome") End If End Sub
Output
MADAM is Palindrome

