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

Can*_*gar 2 excel vba

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

请问有人可以帮助我吗?

非常感谢!

Gar*_*ent 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
Run Code Online (Sandbox Code Playgroud)

  • @BruceWayne我必须自己查一下,我认为具体的东西必须具有历史意义.我喜欢这个小小的花絮,现在它存放在我的大脑中. (2认同)