다음 사항에 도움을 주셔서 감사합니다.VBA에서 문자열 분리 문제가 있습니다.
VBA에서 일부 데이터를 분리해야 파일 명명 시스템에서 사용할 별도의 변수로 설정할 수 있습니다. 시작시 세 strVal는 데이터가 코드를 테스트하기에 코드를 실행하기위한 3 개 가지 선택이 있습니다
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
:
나는 다음과 같은 코드가 있습니다. \의 수는 상황에 따라 다를 수 있습니다.
우리가 필요로하는 결과는 다음
데이터 세트 1 strVal2 = KingMcManaman strVal3 = 니콜슨
데이터 세트 2 strVal2 = F strVal3 = A5 KHAKI
데이터 세트 3 strVal2 = BPD strVal3 = A5 GROUP
내가 입력 해 주셔서 감사합니다. 이 행운은 없었습니다.
감사합니다,
샘
감사합니다. 나는 이것을 사용하고 치료를했습니다. – SCGB
+1 효율적으로 완료되었습니다. – brettdj