I have a spreadsheet that copies a load of files, based on a file path in Column A and pastes them based on a file path in Column B.
In some cases, some of the file paths specified in Column A won't exist. At the moment these errors just come up as a message box. I want to add something to my vba so that these errors are outputted to a tab 'Errors' in the same workbook, with this list being cleared every time that the macro is run. I am struggling though!
This is the original vba
In some cases, some of the file paths specified in Column A won't exist. At the moment these errors just come up as a message box. I want to add something to my vba so that these errors are outputted to a tab 'Errors' in the same workbook, with this list being cleared every time that the macro is run. I am struggling though!
This is the original vba
VBA Code:
Sub CopyFiles()
Dim src As String, dst As String, fl As String
Dim lr As Long
'Source directory
'Range("A2").Select
lr = Cells(Rows.Count, "C").End(xlUp).Row
For X = 2 To lr
src = Range("A" & X).Value
'Destination directory
dst = Range("B" & X).Value
'Filename
fl = Range("F" & X).Value
On Error Resume Next
'get project id
FileCopy src & "\" & fl, dst & "\" & fl
If Err.Number <> 0 Then
MsgBox "Copy error: " & src & "\" & fl
End If
Next X
On Error GoTo 0
MsgBox ("Complete!")
End Sub