VBA:拆分并更改字符串

时间:2013-06-13 13:10:36

标签: string vba

我需要改变,例如跟随字符串153,154,155,156

153**,**154**,**155**,**156

所以,**,**

我怎么能在VBA中做到这一点?

3 个答案:

答案 0 :(得分:4)

MSDN上的

Replace()

Sub ReplaceInStr()

    Dim str As String
    str = "153,154,155,156"
    str = Replace(str, ",", "**,**")
    MsgBox str

End Sub

答案 1 :(得分:4)

不是更好,但不同:

Sub SplitJoin()

    Debug.Print Join(Split("153,154,155,156", ","), "**,**")

End Sub

答案 2 :(得分:3)

试试这个:

Dim s as String
s = "153,154,155,156"
s = Replace(s, ",", "**,**")