View Single Post
 
Old 04-13-2021, 10:36 AM
Rolo18 Rolo18 is offline Windows 10 Office 2016
Novice
 
Join Date: Mar 2020
Posts: 20
Rolo18 is on a distinguished road
Default Copy files from one folder to another using a list

Hello,

I'm currently struggling to find a solution to a Macro to grab files from a source folder and copy them over the destination folder.

I will have the list of files I need copy over on A1, A2, A3... etc

I was trying to use this technique but I am getting an error run time error '438'

Any ideas what I have wrong, or does anyone have a similar working macro?
Code:
Sub copyfiles()
Dim m As Variant
Dim copier
Dim FileName As String
Dim FileType As String

    Set copier = CreateObject("Scripting.FileSystemObject")
    FileType = ".txt"
    For m = 2 To 4
    FileName = Cells(m, 1).Value

    copier.copyfiles "C:\Users\roberto.rodriguezram\Desktop\Source\" & FileName & FileType, "C:\Users\roberto.rodriguezram\Desktop\Destination\"
    Next
End Sub
Reply With Quote