よろしければ、以下の点にご協力いただけますと幸いです。
ファイル命名システムで使用される個別の変数として設定できるように、VBA で一部のデータを分離する必要があります。
次のコードがあります。
Sub StripSlash1()
Dim strVal As String, strVal2 As String, strVal3 As String, strVal4 As String
'strVal = "jack\tom\rich\Nicolson\KingMcManaman"
'strVal = "L:\Pictures\A B C\A5 GROUP\A5 KHAKI\f"
strVal = "L:\Pictures\A B C\A5 GROUP\BPD"
Cells(2, 5).Formula = strVal
strVal2 = Right(strVal, InStr(strVal, "\") - 1)
Cells(2, 6).Formula = strVal2
strVal4 = Left(strVal, InStrRev(strVal, "\") - 1)
Cells(2, 7).Formula = strVal4
strVal3 = Right(strVal4, InStr(strVal4, "\") - 1)
Cells(2, 8).Formula = strVal3
End Sub
最初の 3 つの strVal は、コードをテストするためにコードを実行するデータの 3 つの異なる選択肢です。\ の数は状況によって異なる場合があります。
必要な結果は次のとおりです。
データセット 1 strVal2 = KingMcManaman strVal3 = Nicolson
データセット 2 strVal2 = f strVal3 = A5 KHAKI
データセット 3 strVal2 = BPD strVal3 = A5 GROUP
私は運がなかったので、あなたの意見に感謝します。
よろしく、
サム