VBA Function: Right

The VBA Right function returns a specified number of characters from a string starting from the right side.

Usage:

Right(text, num_chars)


Example of Usage

Using the Right function to retrieve a variable number of characters from a string starting from the right:

Sub example()
    
    MsgBox Right("www.excel-pratique.com", 1) 'Returns: m
    MsgBox Right("www.excel-pratique.com", 2) 'Returns: om
    MsgBox Right("www.excel-pratique.com", 3) 'Returns: com
    MsgBox Right("www.excel-pratique.com", 4) 'Returns: .com
    MsgBox Right("www.excel-pratique.com", 5) 'Returns: e.com
    MsgBox Right("www.excel-pratique.com", 10) 'Returns: atique.com
    MsgBox Right("www.excel-pratique.com", 50) 'Returns: www.excel-pratique.com

End Sub
The function that returns a specified number of characters from the left side is the Left function.
To extract characters from within a string, you can use the Mid function.