JoaMika
JoaMika

Reputation: 1827

Excel VBA extract words from string

I have a string in this format:

>word1>longword2>longerword3>word4>anotherword5>

In VBA I am looking to extract all words between the characters >. Any guidelines will be much appreciated - words contain numbers and special characters and are not fixed in length.

Upvotes: 0

Views: 10052

Answers (2)

bobby4078
bobby4078

Reputation: 103

Use the split function : http://msdn.microsoft.com/library/6x627e5f(v=vs.90).aspx

There is an example at the end of the link.

You need to use something like:

Dim TestArray() As String;
TestArray = Split(myString, ">")

Upvotes: 2

eventHandler
eventHandler

Reputation: 1211

this code will solve your problem

Dim longString as String
longString = "word1>longword2>longerword3>word4>anotherword5>"

Dim arrayString() as String
arrayString = Split(longString, ">")

Upvotes: 1

Related Questions