office交流網--QQ交流群號

Access培訓群:792054000         Excel免費交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

Split函數的使用方法

2019-11-16 01:30:00
zstmtony
原創
8356
Sub test1()
    Dim strTest As String
    Dim arrResult() As String
    Dim i As Integer
    strTest = "abc, edf, hij, klm"
    arrResult = VBA.Split(strTest , ",", 3)
    For i = LBound(arrResult) To UBound(arrResult)
        Debug.Print Trim(arrResult(i))
    Next i
End Sub


文本不區分大小寫


Sub test2()
    Dim strTest As String
    Dim arrResult() As String
    Dim i As Integer
    strTest = "AAAsBBBSCCCsDDDsEEEFF"
    arrResult = VBA.Split(strTest , delimiter:="s", compare:=vbTextCompare)
    For i = LBound(arrResult) To UBound(arrResult)
        Debug.Print Trim(arrResult(i))
    Next i
End Sub


分享