pgbigorokuのブログ

プログラムの再利用できそうなコードをアップ

EXCEL VBA 文字列検索をして1つ目の区切り位置までの値を取得

    Debug.print=nistr文字列検索をして1つ目の区切り位置までの値を取得(strSelection, ",")

' 文字列検索をして1つ目の区切り位置までの値を取得
'https://pgbigoroku.hatenablog.com/entry/2022/08/23/161312
' 2021/8/21
Public Function nistr文字列検索をして1つ目の区切り位置までの値を取得(ByVal pstrTarget As String, ByVal pstrDivide As String)
    Dim intInstr As Integer
    intInstr = InStr(pstrTarget, pstrDivide)
    If intInstr = 0 Then
        nistr文字列検索をして1つ目の区切り位置までの値を取得 = pstrTarget
    Else
        nistr文字列検索をして1つ目の区切り位置までの値を取得 = Left(pstrTarget, intInstr - 1)
    
    End If
End Function