[VBA]半角スペースで文字列を分割するサンプル

2021年5月4日

書式
Split(文字列," “)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Sub funcA()
Dim resA As Variant
Dim strP As String
strP = "AA01 BB02 CC03 DD04"
resA = Split(strP, " ")
For Each g In resA
Debug.Print g
Next
End Sub
Sub funcA() Dim resA As Variant Dim strP As String strP = "AA01 BB02 CC03 DD04" resA = Split(strP, " ") For Each g In resA Debug.Print g Next End Sub
Sub funcA()
    Dim resA As Variant
    Dim strP As String
    strP = "AA01 BB02 CC03 DD04"
    
    resA = Split(strP, " ")
    
    For Each g In resA
        Debug.Print g
    Next
End Sub

実行結果
AA01 BB02 CC03 DD04

Excel VBA

Posted by arkgame