split function

"text = "Mary had a little lamb"

Using the statement "wordcount = UBound(Split(text, " ")) + 1"

to get a wordcount for a document. Can the split function be used further to put the words into an array by using the single space as a divider?







Comments

  • : "text = "Mary had a little lamb"
    :
    : Using the statement "wordcount = UBound(Split(text, " ")) + 1"
    :
    : to get a wordcount for a document. Can the split function be used further to put the words into an array by using the single space as a divider?
    :
    The Split function already returns an array.
    What you need is to assign the returned array to a variable so you can manipulate it, eg:

    Dim x As Variant
    x = Split(text, " ")

    Now you can access the array with x(1), x(2), etc.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion