VBA RIGHT Function

HomeVBA Functions LIST (Category Wise)How to use the VBA RIGHT Function (Syntax + Example)

What is VBA RIGHT Function

how to use it

To use VBA's RIGHT function you need to understand its syntax and arguments:

Syntax

Right(Str, Length)

Arguments

  • Str: The string from which you want to extract a sub-string.
  • Length: The integer to specify the length of the sub-string.

Example to use RIGHT Function in VBA

To practically understand how to use VBA RIGHT function, you need to go through the below example where we have written a vba code by using it:

Sub example_RIGHT()
Range("B1").Value = Right(Range("A1"), 6)    
End Sub

In the above code, we have used RIGHT to get the 6 characters from the right side of the cell A1 (Excel Champs) and get it in the cell B1. It has returned the value (Champs) in the result as these are the first 6 characters we have in the cell A1.

Related Functions

About the Author

puneet one point one

Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can find him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.