Excel VBA 从字符串中提取单词
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23696209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Excel VBA extract words from string
提问by Joanna Mikalai
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.
在 VBA 中,我希望提取字符之间的所有单词>
。任何指导方针将不胜感激 - 单词包含数字和特殊字符,并且长度不固定。
回答by bobby4078
Use the split function : http://msdn.microsoft.com/library/6x627e5f(v=vs.90).aspx
使用拆分功能: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, ">")
回答by eventHandler
this code will solve your problem
此代码将解决您的问题
Dim longString as String
longString = "word1>longword2>longerword3>word4>anotherword5>"
Dim arrayString() as String
arrayString = Split(longString, ">")