I am trying to copy a specific list of excel files to a destination folder. The goal is to have a macro that I can click and will allow me to select the destination folder for the defined list of files, which are then copied to the destination folder. Can you please help me with the following problem.
Current problem: Only one file from the array is being saved down in the target folder and the file type = file, not xlsm. I think has something to do with the FSO portion of the script but i am not sure what the solution is.
Sub Copyfiles_to_folder()
Dim sSource
Dim sDest As String
Dim FSO As New FileSystemObject
Dim vYearFolder As Variant
Dim Directory as Variant
'To select destination folder with changing date
vYearFolder = BrowseForFolder("K:\FolderSource")
sDest = vYearFolder
'list of excel files that I want to be moved to the destination folder
Directory = array ("P:\file1.xlsm", "P:\file2.xlsm", "P:\file3.xlsm", "P:\file4.xlsm")
For each sSource in Directory
FSO.CopyFile sSource, sDest, True
Next
End Sub
Directory
variable isn't going to work though. TryDim Directory as Variant
Also, the name of your routine can't have spaces.