VBA Right Function
எக்ஸ்செல் இல் உள்ளமைக்கப்பட்ட பல உரை செயல்பாடுகள் பயனர்களுக்கு உரை அடிப்படையிலான தரவுடன் வேலை செய்வதை எளிதாக்குகின்றன.ஒரு குறிப்பிட்ட தரவிலிருந்து எழுத்துக்குறிகளைப் பிரித்தெடுக்கும் இந்த செயல்பாடுகளில் சில, LEN, LEFT மற்றும் RI ஆகியவை அடங்கும்.
What is VBA Right Function?
The VBA RIGHT Function is used to extract the length of characters (or a substring) only from the right side of the supplied string.
இந்த செயல்பாடு VBA குறியீட்டில் பயன்படுத்தப்படும் போது சரத்தின் முடிவில் உள்ள உள்ளீட்டு சரத்திலிருந்து ஒரு சப்ஸ்ட்ரைங்கைத் தருகிறது. வேறு விதமாகச் சொல்வதானால், VBA RIGHT செயல்பாடு in இலிருந்து சப்ஸ்ட்ரைங்கை மட்டுமே மீட்டெடுக்கிறது.
Syntax
Parameter
- String (required): நாங்கள் பிரித்தெடுக்க விரும்பும் சரத்தின் நீளம் சர அளவுருவால் குறிக்கப்படுகிறது.
- Length (required): இந்த நீள வாதம் குறிப்பிட்ட சரத்தின் வலது பக்கத்தில் இருந்து எத்தனை எழுத்துக்களை மீட்டெடுக்க விரும்புகிறீர்கள் என்பதை மட்டுமே குறிக்கிறது.
Return
The VBA RIGHT Function returns a substring after extracting the rightmost string from the main string.
Points to Remember
- The VBA RIGHT function returns a string-based output for a given string.
- IF the specified string argument is Null, this function will return Null as the output.
- As the name suggests, the VBA RIGHT function extracts only the rightmost characters from the string.
- When the RIGHT function is combined with the InStr function, we can find the space in VBA; by this, a user can easily differentiate the word in the specified string.
Examples
#RIGHT Function Example 1: Fetch the last name from the string “Reema Panda”.
உள்ளமைக்கப்பட்ட செயல்பாடுகளில் ஒன்றான VBA RIGHT, ஒரு சரம் அல்லது பயனர் வழங்கிய மதிப்பின் ஒரு பகுதியை மட்டுமே (சரத்தின் வலது பக்கத்திலிருந்து) மீட்டெடுக்க பயனர்களால் அடிக்கடி பயன்படுத்தப்படுகிறது. பின்வரும் வழிமுறைகள் இருக்கும்.
Step 1: Open the VBA developer tab. Go to Excel worksheet, from the ribbon tab click on developer window -> visual basic editor or directly click on the shortcut keywords Alt +F11.
Step 2: The VB Editor window will be displayed. The next step is to create a module. From the ribbon tab click on Insert-> Click on Module.

Step 3: You will notice, VBA will insert a new module window. Start the program by introduce your macro name followed by the declaration of the variable.
Step 4: Next, we will incorporate the RIGHT function. In the arguments, we will pass the String, and in the length argument, we will pass 5 since we want to extract the first 5 characters from the rightmost part of the String.
Step 5: Store the fetch value in our variable and later return the variable using MsgBox.
- Sub RIGHT_Function_Example1()
- ‘Declaring the string variable
- Dim LstNme As String
- ‘Using the Right function to extract the last name
- LstNme = RIGHT(“Reema Panda”, 5)
- ‘return the output
- MsgBox LstNme
- End Sub

Output
இயக்கு என்பதைக் கிளிக் செய்யவும் அல்லது உங்கள் மேக்ரோவைத் தொடங்க F5 விசையைப் பயன்படுத்தவும்.இதன் விளைவாக, சரத்தின் வலது பக்கத்திலிருந்து முதல் ஐந்து எழுத்துக்களைக் கொண்ட ஒரு எம்.எஸ்.ஜி.பாக்ஸை வி.பி.ஏ உருவாக்கும் என்பதை நீங்கள் காண்பீர்கள்.

#RIGHT Function Example 2: Dynamically fetch the last name from employee table.
Excel அட்டவணையில் இருந்து கடைசி பெயரை நீக்குமாறு அடிக்கடி கேட்கப்படுவீர்கள்.இந்த வகையான சிக்கல்களைத் தீர்ப்பதில் VBA RIGHT செயல்பாடு ஒரு பெரிய உதவியாகும். கீழே ஊழியர்களின் அட்டவணை பட்டியலிடப்பட்டுள்ளது.பார்ப்போம்.

Step 1: Open the VBA developer tab. Go to Excel worksheet, from the ribbon tab click on developer window -> visual basic editor or directly click on the shortcut keywords Alt +F11.
Step 2: The VB Editor window will be displayed. The next step is to create a module. From the ribbon tab click on Insert-> Click on Module.

Step 3: You will notice, VBA will insert a new module window. Start the program by introduce your macro name followed by the declaration of the variable.
Refer to the below given macro code:
- Sub RIGHT_Function_Example2()
- ‘Declaring the variables
- Dim k As String
- Dim L As String
- Dim S As String
- Dim i As Integer
- End Sub
Step 4: Since we have to apply the function for a range of cells in Excel so we will incorporate the FOR loop. Start loop and assign variable LstNme the result of the VBA RIGHT function.
- Sub RIGHT_Function_Example2()
- ‘Declaring the variables
- Dim k As String
- Dim L As String
- Dim S As String
- Dim i As Integer
- ‘Start the for loop
- For i = 2 To 9
- L = Len(Cells(i, 1).Value)
- S = InStr(1, Cells(i, 1).Value, ” “)
- Cells(i, 3).Value = Right(Cells(i, 1), L – S)
- Next i
- End Sub
Step 5: Just to confirm that your program has run successfully, add a MsgBox displaying a message.
- Sub RIGHT_Function_Example2()
- ‘Declaring the variables
- Dim k As String
- Dim L As String
- Dim S As String
- Dim i As Integer
- ‘Start the for loop
- For i = 2 To 9
- L = Len(Cells(i, 1).Value)
- S = InStr(1, Cells(i, 1).Value, ” “)
- Cells(i, 3).Value = Right(Cells(i, 1), L – S)
- Next i
- ‘Displaying the message using MsgBox
- MsgBox (“All the Last names are successfully fetched!”)
- End Sub

Output
இயக்கு என்பதைக் கிளிக் செய்யவும் அல்லது உங்கள் மேக்ரோவைத் தொடங்க F5 விசையைப் பயன்படுத்தவும்.இதன் விளைவாக, VBA ஒரு MsgBox ஐ வெளியிடுவதையும், ஊழியர் அட்டவணையில் இருந்து ஒவ்வொரு ஊழியரின் கடைசி பெயர்களையும் மீட்டெடுப்பதையும் நீங்கள் காண்பீர்கள்.
