The Microsoft Excel RIGHT function extracts a substring from a string starting from the right-most character.


The RIGHT function is a built-in function in Excel that is categorized as a String/Text Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the RIGHT function can be entered as part of a formula in a cell of a worksheet. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.


Syntax


  • =RIGHT(A1, 4)
    Result: "soup"

    =RIGHT("techonthenet", 6)
    Result: "thenet"

    =RIGHT(A2, 6)
    Result: "et.com"

    =RIGHT("Excel", 3)
    Result: "cel"

    =RIGHT("Microsoft")
    Result: "t"


Example (as VBA Function)

  • The RIGHT function can also be used in VBA code in Microsoft Excel.
    Let's look at some Excel RIGHT function examples and explore how to use the RIGHT function in Excel VBA code:
    Dim LResult As String

    LResult = Right("Alphabet",3)
    The variable LResult would now contain the value of "bet".


All the above can also be used with the LEFT function



For further information see attached document