I learnt how to copy multiple files from a single folder to multiple folders depending on file name in Excel sheet.
Sub MoveSelectedfiles()
Dim FSO As Scripting.FileSystemObject
Dim fl As Scripting.File
Dim sourcefldr As Scripting.Folder
Dim destinationFldr As Scripting.Folder
Dim index As Integer
Dim lastrow As Integer
Set FSO = New FileSystemObject
Set sourcefldr = FSO.GetFolder("E:\Testing\Source")
Set destinationFldr = FSO.GetFolder("E:\Testing\Destination")
lastrow = Sheet1.Cells(Rows.Count, 1).End(xlUp).Row
For index = 2 To 10
If (FSO.FileExists(sourcefldr.Path & "\" & Sheet1.Range("A" & index).Value)) Then
FSO.MoveFile sourcefldr.Path & "\" & Sheet1.Range("A" & index).Value, destinationFldr.Path & "\"
End If
Next index
End Sub
I have to define the exact file name. I would like to write even half/incomplete file name.
E.g. If a file name is "Excel training makes easy" and in the Excel sheet I write "Excel training".