How to get a particular part of a String

前端 未结 3 1013
南笙
南笙 2020-12-18 06:56

I am writing a macro in Excel where I need to get a substring from a String. It\'s like this.

~/tester/test/hai/bye
~/stack/overflow/hai/bye
<
3条回答
  •  别那么骄傲
    2020-12-18 07:22

    Try this:

    Sub Macro1()
        Dim text As String, result As String
        text = "~/tester/test/hai/bye"
        result = Mid(text, 3, InStr(3, text, "/") - 3)
        'MsgBox is for demo only
        MsgBox result
    End Sub
    

提交回复
热议问题