Splitting

T

Tree*Rat

how do i get VBA to split items that are seperated by a colon ;

ie this;that;andmore

split into vars

var1 = this
var2 = that
var3 = andmore

Idealy I it would be split into an array
 
B

Bob Phillips

The clue is in the subject

myVar = Split(the_text,";")

myVar is then a variant array.
 
R

Rick Rothstein

To follow up on Bob's post... you can also declare a dynamic String variable
and assign the Split values to that instead.

Dim MyStringArray() As String
MyStringArray = Split(YourTextString, ";")

Note that all arrays created by the Split function are **always** zero-based
arrays (even if you use Option Base 1 in your code modules).
 
T

Tree*Rat

To follow up on Bob's post... you can also declare a dynamic String
variable and assign the Split values to that instead.

Dim MyStringArray() As String
MyStringArray = Split(YourTextString, ";")

Note that all arrays created by the Split function are **always**
zero-based arrays (even if you use Option Base 1 in your code
modules).

cool, thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top