String split in VBA in Excel

Within VBA I have a string that is actually taken from a cell, this could be any length and is a list of usernames seperated by a coma.

What I need to be able to do is split this string into an array, with each user name appearing in a different element of the array, i.e:

OrginalString = Fred,Smith

Split down to:

String(0) = Fred
String(1) = Smith

Answer:

Dim splitString As Variant

splitString = Split(Range("A1").Value, ",")

 

(for formulas, depending on your country, you might have to change ; with , or the opposite

 Other excel answers

 

 

You can find similar Excel Questions and Answer hereunder

1) How can I loop through all WorkSheets and get their names using VBA?

2) How can I turn off Alerts using VBA?

3) How can I add a Timestamp after macro execution?

4) How to modify strings in VBA, what are the functions you can manipulate strings with

5) VBA delete entire row if contains certain text in Excel

6) How can I list all files in a folder using VBA?

7) How to hide and unhide rows and columns in excel VBA

8) How can I get users to select a folder to save the output of my macro?

9) How to use the trace error function in VBA

10) Line break in VBA message box in Excel

 

Here the previous and next chapter