
04-13-2021, 03:26 PM
|
Novice
|
|
Join Date: Mar 2020
Posts: 20
|
|
Quote:
Originally Posted by rollis13
You can test if the file to be copied exists, like this:
Code:
Option Explicit
Sub copyfiles()
Dim m As Variant
Dim FileName As String
Dim FileType As String
FileType = ".txt"
For m = 2 To 4
FileName = Cells(m, 1).Value
If Dir("C:\Users\roberto.rodriguezram\Desktop\Source\" & FileName & FileType) <> "" Then
FileCopy "C:\Users\roberto.rodriguezram\Desktop\Source\" & FileName & FileType, _
"C:\Users\roberto.rodriguezram\Desktop\Destination\" & FileName & FileType
End If
Next
End Sub
|
Thank you!
|