VBA Split function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Split Function Description

The VBA Split function splits any string into substrings separated by a given delimiter, returning a VBA Array containing the split substrings.


The syntax for the Split function in VBA is:

Split ( expression [,delimiter] [,limit] [,compare] )


The string to be split into separate substrings separated by the given delimiter.

Optional. The delimiter which separates the expression into separate substrings. By default this is a whitespace character (” “).

Optional. The limit of substrings to be returned by splitting the expression into separate substrings. By default this equals -1 which means all substrings are to be returned.

Optional. The type of comparison to perform when looking for the substring. This can be one of the following VBA Constants:

Constant Value Description
CompareMethod.Binary 0 Binary comparison (distinguishes letter case)
CompareMethod.Text 1 Textual comparison (ignores letter case)

Other Notes

The Split function will return a VBA Array containing the splitted substrings. The numbering of the first item in the VBA Array starts at 0.

Example usage

The Split function can be used in VBA code. Let’s look at some VBA Split function examples:

Split "Hello World!"
'Result: "Hello", "World!"

Split "", "."
'Result: "1", "2", "3", "4", "5"

Simply the best place to learn VBA!

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match