VBA Split Function
VBA Excel ஐக் கையாளும்போது பயனர் அடிக்கடி ஒரு சரத்தை ஒரு குறிப்பிட்ட எல்லை வரையறையைப் பொறுத்து துணை அடுக்குகளாகப் பிரிக்க வேண்டியிருக்கும்.எடுத்துக்காட்டாக, உங்களுக்கு ஒரு இருப்பிடம் வழங்கப்பட்டால், நீங்கள் VBA Split function பயன்படுத்தலாம்.
What is Split Function?
“The SPLIT String function is used to split a string into substrings based on the supplied delimiter. It returns a zero-based, one-dimensional array holding the parts of substrings.”
String/Text Functions வகையின் கீழ் உள்ளமைக்கப்பட்ட செயல்பாடு VBA Split function ஆகும்.இந்த செயல்பாடு Microsoft Visual Basic Editor இல் VBA மேக்ரோவில் குறியிடப்பட்டுள்ளது. Split என்பது Excel function ஆகும்.
Syntax
Split (Expression, [Delimiter], [Limit], [Compare])
Parameter
Expression (required): டிலிமிட்டரின் அடிப்படையில் நீங்கள் பிரிக்க விரும்பும் உள்ளீட்டு சரம் இந்த அளவுருவால் குறிக்கப்படுகிறது.
Delimiter (optional): சரத்தைப் பிரிக்கப் பயன்படுத்தப்படும் டிலிமிட்டர் இந்த அளவுருவால் குறிக்கப்படுகிறது.பொதுவாக, “வெளிப்பாடு” வாதம் சம்பந்தப்பட்டது. உங்களிடம் ஒரு சரம் உள்ளது என்று சொல்லலாம் “ஹலோ, உலகம், இது, இது, என், புரோ.
Limit (optional): பயனர் திருப்பித் தர விரும்பும் மொத்த சப்ஸ்ட்ரிங்களின் எண்ணிக்கை இந்த விருப்பத்தால் குறிப்பிடப்படுகிறது.எடுத்துக்காட்டாக, இந்த வாதத்தில் முதல் மூன்று துணைக்குறிப்புகளை நீங்கள் பிரித்தெடுக்க விரும்பினால் 3 ஐ வழங்குவீர்கள்.
Compare (optional): சப்ஸ்ட்ரிங்ஸை மதிப்பிடும் போது இந்த விருப்பம் பயனர் ஸ்பிளிட் செயல்பாட்டில் பயன்படுத்த விரும்பும் ஒப்பீட்டை வழங்குகிறது. ஒப்பிட சில யோசனைகள் இங்கே:
- When Compare is 0: 0 represents the Binary comparison. It is helpful when your delimiter is a text string (for example XYZ), this would be case-sensitive. ‘XYZ’ will be different from small case ‘xyx’.
- When Compare is 1: 1 represents the Text comparison. It is helpful if your delimiter is a text string (for example XYZ), even if you have ‘xyz’ in the ‘Expression’ string, it would be considered as a delimiter.
Return
The VBA Split function returns a zero-based, one-dimensional array holding the parts of substrings.
Examples
Split Program 1: Split the String using the default space delimiter.
String = Welcome to the world of VBA programming
உள்ளமைக்கப்பட்ட செயல்பாடு VBA Split உதவியுடன், குறிப்பிட்ட எல்லையின் அடிப்படையில் ஒரு சரத்தை விரைவாக துணை அடுக்குகளாகப் பிரிக்கலாம். பிளவு செயல்பாட்டைப் பயன்படுத்தும் ஒரு VBA மேக்ரோவை உருவாக்குவதற்கான நடைமுறைகள்.

Refer to the below given macro code:
- Sub Split_StringFunction_Example1()
- ‘Declaring a variable
- Dim TextStr As String
- Dim Result() As String
- TextStr = “Welcome to the world of VBA programming.”
- End Sub
We will call the Split function, pass the string ‘Textstr’ in it and store the value in the result method.
Refer to the below given macro code:
- Sub Split_StringFunction_Example1()
- ‘Declaring a variable
- Dim TextStr As String
- Dim Result() As String
- TextStr = “Welcome to the world of VBA programming.”
- ‘Splitting the string using the split function using the default space delimeter
- Result() = Split (TextStr)
- End Sub

Output
F5 விசையை அழுத்துவது குறியீட்டை செயல்படுத்தும் மற்றும் முடிவுகளை மீட்டெடுக்கும்.இதன் விளைவாக, பிளவு செயல்பாடு சரத்தை “உரைகளை” பல துணை அடுக்குகளாகப் பிரிக்கிறது மற்றும் ஒவ்வொன்றையும் முடிவு arr இல் வைக்கிறது.
- Result(0) stores the substring “Welcome”
- Result(1) stores the substring “To”
- Result(2) stores the substring “World”
- Result(3) stores the substring “of”
- Result(4) stores the substring “VBA”
- Result(5) stores the substring “programming.”
NOTE: In this program, the delimiter argument is omitted so it takes the space character as the default delimiter.
Split Example 2 – Count the Number of Words present in a string
ஒரு அறிக்கையில் உள்ள மொத்த வார்த்தைகளின் எண்ணிக்கையை தீர்மானிக்க விபிஏ ஸ்பிலிட் செயல்பாட்டைப் பயன்படுத்துவதும் கண்ணியமானது.திட்டம் முன்பு செய்ததைப் போலவே செயல்படும்; ஒரே தந்திரம் எத்தனை துன்பங்களை எண்ணுவதுதான்.
Step 1: Go to the VBA developer tab either by clicking the shortcut keywords Alt +F11 or click on developer window -> visual basic editor.
Step 2: The VB Editor will appear. The next step is to create a module. Right-clicking on the VBA Project-> Click on Insert-> Click on Module.

Refer to the below given macro code:
- ‘VBA program to find the word count using split function
- Sub Split_Function_Example2()
- ‘Declaring the variables
- Dim TxtStr As String
- Dim WordCt As Integer
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel VBA is an excellent programming language.”
- End Sub
We will call the Split function, pass the string ‘Textstr’ in it and store the value in the result method.
Refer to the below given macro code:
- ‘VBA program to find the word count using split function
- Sub Split_Function_Example2()
- ‘Declaring the variables
- Dim TxtStr As String
- Dim WordCt As Integer
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel VBA is an excellent programming language.”
- ‘Using split function to string the string using default delimiter
- Output = Split(TxtSt)
- End Sub
You Bound முறையைப் பயன்படுத்தி வரிசையின் மேல் எல்லையைக் கண்டறிதல்.வெளியீட்டு வரிசை தளம் 0 என்பதால், மதிப்புக்கு 1 ஐச் சேர்ப்போம், இதன் விளைவாக வரும் சொல் எண்ணிக்கையைக் காண்பிக்க Msg Box ஐப் பயன்படுத்துவோம்.

Refer to the below given macro code:
- ‘VBA program to find the word count using split function
- Sub Split_Function_Example2()
- ‘Declaring the variables
- Dim TxtStr As String
- Dim WordCt As Integer
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel VBA is an excellent programming language.”
- End Sub
String "Textstr" ஐ ஒரு அளவுருவாகக் கொண்டு பிளவு செயல்பாட்டைப் பயன்படுத்திய பிறகு மதிப்பை சேமிக்க முடிவு முறையைப் பயன்படுத்துவோம்.
Refer to the below given macro code:
- ‘VBA program to find the word count using split function
- Sub Split_Function_Example2()
- ‘Declaring the variables
- Dim TxtStr As String
- Dim WordCt As Integer
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel VBA is an excellent programming language.”
- ‘Using split function to string the string using default delimiter
- Output = Split(TxtSt)
- End Sub
UBound முறையைப் பயன்படுத்தி வரிசையின் மேல் எல்லையைக் கண்டறிதல்.வெளியீட்டு வரிசை தளம் 0 என்பதால், மதிப்புக்கு 1 ஐச் சேர்ப்போம், இதன் விளைவாக வரும் சொல் எண்ணிக்கையைக் காண்பிக்க MsgBox ஐப் பயன்படுத்துவோம்.
- ‘VBA program to find the word count using split function
- Sub Split_Function_Example2()
- ‘Declaring the variables
- Dim TxtStr As String
- Dim WordCt As Integer
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel VBA is an excellent programming language.”
- ‘Using split function to string the string using default delimiter
- Output = Split(TxtSt)
- ‘using the UBound function to find upper bound of the array
- ‘adding 1 since array starts from 0
- WordCt = UBound(Output()) + 1
- ‘displaying the output
- MsgBox “The Word Count is ” & WordCt
- End Sub

Output
Run the code by pressing the F5 key and fetching the output. As a result, it will return the message box displaying the word count as 7.

SPLIT Example 3 – Using a comma Delimiter to split the String
முதல் இரண்டு எடுத்துக்காட்டுகளில், நாங்கள் வெளிப்பாடு வாதத்தை மட்டுமே பயன்படுத்தினோம் என்பதையும், எல்லை வரையறையில், நாங்கள் எப்போதும் நிலையான விண்வெளி எழுத்தைப் பயன்படுத்தினோம் என்பதையும் நீங்கள் கவனிப்பீர்கள்.
Step 1: Go to the VBA developer tab either by clicking the shortcut keywords Alt +F11 or click on developer window -> visual basic editor.
Step 2: The VB Editor will appear. The next step is to create a module. Right-clicking on the VBA Project-> Click on Insert-> Click on Module.

Step 3: The Moule window will be inserted. Introduce the macro name followed by the declaration of the variable. Next, we will introduce a method named as Result().
Refer to the below given macro code:
- ‘VBA program to find the word count using split function with a Delimiter
- Sub Split_Function_Example3()
- ‘Declaring the variables
- Dim TxtStr As String
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel,VBA,is,an,excellent,programming,language.”
- End Sub
நாங்கள் பிளவு செயல்பாட்டைப் பயன்படுத்துவோம் மற்றும் சரம் மற்றும் டிலிமிட்டரை உள்ளீடுகளாக கடப்போம் (,).அடுத்து, வரிசையின் மேல் மற்றும் கீழ் எல்லையைப் பெற UBOUND மற்றும் LBOUND செயல்பாட்டைப் பயன்படுத்துவோம்.
- ‘VBA program to find the word count using split function with a Delimiter
- Sub Split_Function_Example3()
- ‘Declaring the variables
- Dim TxtStr As String
- ‘Declaring an output method
- Dim Output() As String
- TxtSt = “Excel,VBA,is,an,excellent,programming,language.”
- ‘Using split function to string the string using default delimiter
- Output = Split(TxtSt, “,”)
- For i = LBound(Output()) To UBound(Output())
- DisplayTextDisplayText = DisplayText & Output(i) & vbNewLine
- Next i
- ‘displaying the output
- MsgBox DisplayText
- End Sub

Output
Run the code by pressing the F5 key and fetching the output. As a result, it will return the message box displaying all the substrings.
