Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

VBA-Excel: Array Functions – Split()

Descrip­tion:

 Split() Func­tion returns one dimen­sional array con­tain­ing the sub­strings, after split­ting the main string based upon the delim­iter provided.

For­mat:

Split(str­Main­String [, delimiter[,intlimit[, vbCompare]]])

Argu­ments:

  • str­Main­String
    • Manda­tory
    • Type: String
    • String which will be split

  • delim­iter
    • Optional
    • Type: Any
    • The expres­sion based on which the str­Main­String will get split
  • intLimit
    • Optional
    • Type : Numeric
    • No of sub­string to be returned.
  • Com­pare
    • Optional
    • Type: Numeric
    • The type of com­par­i­son to find the string in the main string, like vbBina­ryCompare ( Value =0), vbTextCom­pare (value=1).

Exam­ple :

 
Function FnSplit()
    Dim strMainString
    Dim strTemp    
    strMainString = "This is Split Function Example"    
    arrSplit = Split(strMainString, " ")  
    For i = 0 To UBound(arrSplit)
        strTemp = strTemp & arrSplit(i) & "  " & vbCrLf
    Next    
    MsgBox strTemp
End Function 
Split()

Split()

 

You may also like...

4 Responses

  1. santosh says:

    good tuto­r­ial and example

  2. Pankaj Gupta says:

    it is very help­ful to learn vba.

    Thank u so much sumit ji…

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: