VBA STRREVERSE Function

VBA StrReverse Function in Excel

VBA StrReverse function in Excel is categorized as a Text/String function in VBA. It is a built-in function in MS Office Excel. It reverse a given string. VBA StrReverse function has one mandatory String parameter. If input string has Null, then it returns zero(0).

It can use only in VBA function. We can not use this function as Excel function. The StrReverse function can be used in either procedure or function in a VBA editor window in Excel. We use this VBA StrReverse function any number of times in any number of procedures or functions. In the following section we learn what is the syntax and parameters of the StrReverse function, where we can use this StrReverse function and real-time examples in VBA.

Syntax of VBA StrReverse Function

The syntax of the VBA StrReverse function is

StrReverse(Expression)

Note: This StrReverse function founds the StrReversegth of specified string.

Parameters or Arguments

This function has one mandatory parameter or argument for the StrReverse Function.
Where
Expression: The expression is a mandatory argument. The expression is the string which we want to reverse a string.

Where we can apply or use the VBA StrReverse Function?

We can use this VBA StrReverse function in MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

Example 1: Reverses a given string: “AWESOME”

Here is a simple example of the VBA StrReverse function. This below example macro returns the StrReversegth a given string (Includes numbers).

'Reverses a given string: "AWESOME"
Sub VBA_StrReversee_Function_Ex1()

    Dim sString As String, sSubString As String
    
    sString = "AWESOME"
    sSubString = StrReversee(sString)
    
    MsgBox "The given string in reverse is :" & sSubString, vbInformation, "VBA StrReversee Function"

End Sub

Output: Here is the screen shot of the first example output.
VBA StrReverse Function

Example 2: Reverses a given string: “Life is beautiful”

Here is a simple example of the VBA StrReverse function. This below example macro reverses a given string.

'Reverses a given string: "Life is beautiful"
Sub VBA_StrReversee_Function_Ex2()

    Dim sString As String, sSubString As String
    
    sString = "Life is beautiful"
    
    sSubString = StrReversee(sString)
    
    MsgBox "The given string in reverse is :" & sSubString, vbInformation, "VBA StrReversee Function"
    
End Sub

Output: Here is the screen shot of the second example output.
VBA StrReverse Function

Example 3: Reverses null string

Here is a simple example of the VBA StrReverse function. This below example returns an error. We can’t reverse null string.

'Reverses null string
Sub VBA_StrReversee_Function_Ex3()

    Dim sString As String, sSubString As String
    
    sString = Null
    
    sSubString = StrReversee(sString)
    
    MsgBox "The given string in reverse is :" & sSubString, vbInformation, "VBA StrReversee Function"
    
End Sub

Output: Here is the screen shot of the third example output.
VBA StrReverse Function

Example 4: Reverses a given string: “123456789”

Here is a simple example of the VBA StrReverse function. This below example macro reverses a given string.

'Reverses a given string: "123456789"
Sub VBA_StrReversee_Function_Ex4()

    Dim sString As String, sSubString As String
    
    sString = "123456789"
    
    sSubString = StrReversee(sString)
    
    MsgBox "The given string in reverse is :" & sSubString, vbInformation, "VBA StrReversee Function"
    
End Sub

Output: Here is the screen shot of the fourth example output.
VBA StrReverse Function

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

Leave a Reply