
- VBA Tutorial
- VBA - Home
- VBA - Overview
- VBA - Excel Macros
- VBA - Excel Terms
- VBA - Macro Comments
- VBA - Message Box
- VBA - Input Box
- VBA - Variables
- VBA - Constants
- VBA - Operators
- VBA - Decisions
- VBA - Loops
- VBA - Strings
- VBA - Date and Time
- VBA - Arrays
- VBA - Functions
- VBA - Sub Procedure
- VBA - Events
- VBA - Error Handling
- VBA - Excel Objects
- VBA - Text Files
- VBA - Programming Charts
- VBA - Userforms
- VBA Useful Resources
- VBA - Quick Guide
- VBA - Useful Resources
- VBA - Discussion
VBA - Right
The Right function returns a specified number of characters from the right side of the given input string.
Syntax
Right(String, Length)
Parameter Description
String − A required parameter. Input String from which the specified number of characters to be returned from the right side.
Length − A required parameter. An Integer, which Specifies the number of characters to be returned.
Example
Add a button and add the following function.
Private Sub Constant_demo_Click() var = "Microsoft VBScript" msgbox("Line 1 : " & Right(var,2)) var = "MS VBSCRIPT" msgbox("Line 2 : " & Right(var,5)) var = "microsoft" msgbox("Line 3 : " & Right(var,9)) End Sub
When you execute the above function, it produces the following output.
Line 1 : pt Line 2 : CRIPT Line 3 : microsoft
vba_strings.htm
Advertisements