Enright
08-12-2016, 07:14 AM
Hello!
I have a working macro that will copy a List of Files(beginning with H6) from a Source Folder(B5) to a Destination Folder (B6)
We are working with client files which is never as you expect, so sometimes we will try to copy a file that does not exist in the Source Folder(B5).
What should I add to the code so that it identifies files that were not copied successfully? I can't seem to find any resources that address this.
Sub InvoicePull2()
Dim R As Range
Dim SourcePath As String, DestPath As String, FName As String
SourcePath = Range("B5").Value
DestPath = Range("B6").Value
For Each R In Range("H9 ", Range("H" & Rows.Count).End(xlUp))
FName = Dir(SourcePath & R)
Do While FName <> ""
FileCopy SourcePath & FName, DestPath & FName
FName = Dir()
Loop
Next
End Sub
I have a working macro that will copy a List of Files(beginning with H6) from a Source Folder(B5) to a Destination Folder (B6)
We are working with client files which is never as you expect, so sometimes we will try to copy a file that does not exist in the Source Folder(B5).
What should I add to the code so that it identifies files that were not copied successfully? I can't seem to find any resources that address this.
Sub InvoicePull2()
Dim R As Range
Dim SourcePath As String, DestPath As String, FName As String
SourcePath = Range("B5").Value
DestPath = Range("B6").Value
For Each R In Range("H9 ", Range("H" & Rows.Count).End(xlUp))
FName = Dir(SourcePath & R)
Do While FName <> ""
FileCopy SourcePath & FName, DestPath & FName
FName = Dir()
Loop
Next
End Sub