2
私は2列A
とB
のファイルのリストを持っています。VBAコピーファイルそれは存在しません
A
列がソースでBB
列は、宛先
ソースから宛先へのコピー・ファイル以下のコードです。しかし、目的地が存在する場合、それは私にエラーを与える。それはそれが存在することを見つけるなら、それはanytingをしないように条件は何ですか?
コードに何が間違っていますか?
Sub FC_Copy()
Dim ClientsFolderDestination
Dim fso As New FileSystemObject
Dim rep_destination
Dim source
lastrow = ThisWorkbook.Worksheets("XClients").Cells(Application.Rows.Count, 1).End(xlUp).Row
For i = 5 To lastrow
source = ThisWorkbook.Worksheets("XClients").Cells(i, 1).Value
ClientsFolderDestination= ThisWorkbook.Worksheets("XClients").Cells(i, 2).Value
If fso.FileExists(source) Then
rep_destination = Left(ClientsFolderDestination, Len(ClientsFolderDestination) - Len(fso.GetFileName(ClientsFolderDestination)) - 1)
If Not fso.FolderExists(rep_destination) Then
sub_rep = Split(rep_destination, "\")
myrep = sub_rep(0)
If Not fso.FolderExists(myrep) Then
MkDir myrep
End If
For irep = 1 To UBound(sub_rep)
myrep = myrep & "\" & sub_rep(irep)
If Not fso.FolderExists(myrep) Then
MkDir myrep
End If
Next
End If
fso.CopyFile source, ClientsFolderDestination
End If
Next i
end sub
'iRow'何ですのような先のパスに食料調達するファイルやフォルダ
@SiddharthRout私はコードを編集します – JeanLo
最後の質問が1つあります。あなたはcol AとCol Bの価値は何ですか?ここに入力してください。 –