i have code below to extract Workbooks containing Template with 2021 and Ver 1.1 for eg BR1 GL Report Import Template 2021 Ver 1.1.xlsm
The macro runs but no files are copied to the folder C:\GL Reports\
it appears that this portion o the code needs to be amended
It would appreciated if someone could kindly assist me
The macro runs but no files are copied to the folder C:\GL Reports\
it appears that this portion o the code needs to be amended
Code:
If LCase(fsoFile.Name) Like "*Template 2021 Ver 1.1*.xlsm*" Then
It would appreciated if someone could kindly assist me
Code:
Sub copy_files_from_subfolders()
Dim FSO As Object, fld As Object
Dim fsoFile As Object
Dim fsoFol As Object
SourcePath = "C:\Admin\"
targetPath = "C:\GL Reports\"
'If Right(SourcePath, 1) <> " \" Then SourcePath = SourcePath & " \"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fld = FSO.GetFolder(SourcePath)
If FSO.FolderExists(fld) Then
For Each fsoFol In FSO.GetFolder(SourcePath).SubFolders
For Each fsoFile In fsoFol.Files
If LCase(fsoFile.Name) Like "*Template 2021 Ver 1.1*.xlsm*" Then
fsoFile.Copy targetPath & fsoFile.Name
End If
Next
Next
End If
End Sub