2 つの列に基づいてフォルダーを作成するのに適したスクリプトがありますが、何らかの理由で、末尾にスペースがあるフォルダーが作成されてしまいます。
コードは次のとおりです。
Dim baseFolder As String, newFolder As String
lastrow = wsJL.Cells(Rows.Count, "B").End(xlUp).Row
wsJL.Range("S2:U2").Copy wsJL.Range("S3:U" & lastrow)
Range("J3:M" & lastrow).Calculate
Range("S3:U" & lastrow).Calculate
baseFolder = wbBK1.path & Application.PathSeparator & "Photos" & Application.PathSeparator
'folders will be created within this folder - Change to sheet of your like.
If Right(baseFolder, 1) <> Application.PathSeparator Then _
baseFolder = baseFolder & Application.PathSeparator
For Each cell In Range("S3:S" & lastrow) 'CHANGE TO SUIT
'Company folder - column S
newFolder = baseFolder & cell.Value
If Len(Dir(newFolder, vbDirectory)) = 0 Then MkDir newFolder
'Part number subfolder - column T
newFolder = newFolder & Application.PathSeparator & cell.Offset(0, 1).Value
If Len(Dir(newFolder, vbDirectory)) = 0 Then MkDir newFolder
Next
End With
今、それが巻き込まれているのはこれです:
"The Richmond Group "
タイトルの最後にスペースがあり、フォルダーを作成するときにスペースに変換されないためだと思います。
今、私は S にあり、T はこれです:
S
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($C2,",","")," "," "),".",""),"/","-"),"""",""),"*","")
T
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($D2,",","")," "," "),".",""),"/","-"),"""",""),"*","")
そうは言っても、名前の末尾にあるエンドスペースを削除する方法がわかりません。
誰かがそこで助けることができれば、それは大歓迎です。