如何用vba excel中的多个分隔符分割一个字符串? [英] how to split a string with multiple delimeters in vba excel?

查看:925
本文介绍了如何用vba excel中的多个分隔符分割一个字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Excel VBA拆分多个分米的字符串。其中一个字符串是:

I want to split a string with multiple delimeters using Excel VBA. One of the strings is:

d1-d2 d3 d4  

我们有一个破折号和一个空格作为两个分米。我尝试了 split 函数,但只能使用一个分米。

We have a dash and a space as two delimeters. I tried the split function but it only does it with one delimeter.

推荐答案

p>您可以首先在字符串上先执行 REPLACE ,然后执行拆分:

You could first do a REPLACE on the string first and then do the split:

newString = Replace(origString, "-", " ")
newArray = SPlit(newString, " ")

这篇关于如何用vba excel中的多个分隔符分割一个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆