在VBA中提取字符串的最后两个单词

时间:2016-06-03 14:47:13

标签: excel vba

我试图在vba中提取字符串的最后两个单词。

是的,有人可以帮助我吗?

非常感谢你!

1 个答案:

答案 0 :(得分:6)

考虑:

Sub LastTwoWords()
    Dim s As String

    s = "Now is the time for all good men to come to the aid of the party"
    ary = Split(s, " ")
    MsgBox ary(UBound(ary) - 1)
    MsgBox ary(UBound(ary))
End Sub