VBA-Excel: Array Functions – Split()


 Split() Function returns one dimensional array containing the substrings, after splitting the main string based upon the delimiter provided.


Split(strMainString [, delimiter[,intlimit[, vbCompare]]])


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

  • delimiter
    • Optional
    • Type: Any
    • The expression based on which the strMainString will get split
  • intLimit
    • Optional
    • Type : Numeric
    • No of substring 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).

Example :

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
    MsgBox strTemp
End Function 



You may also like...

4 Responses

  1. santosh says:

    good tutorial and example

  2. Pankaj Gupta says:

    it is very helpful to learn vba.

    Thank u so much sumit ji…

Leave a Reply to Sumit Jain Cancel reply

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

%d bloggers like this: