Hello...
I have a list of source folder and its target folder, but with the code below it only copy to the folder in the second row.
How to make it loop through the list?
The source folder is in column CA and the target folder is in column CB.
Thank you in advance.
I have a list of source folder and its target folder, but with the code below it only copy to the folder in the second row.
How to make it loop through the list?
The source folder is in column CA and the target folder is in column CB.
Thank you in advance.
VBA Code:
Dim sSrcFolder As String, sTgtFolder As String, sFilename As String
Dim c As Range, rPatterns As Range
sSrcFolder = ActiveSheet.Cells(2, 79)
sTgtFolder = ActiveSheet.Cells(2, 80)
Set rPatterns = ActiveSheet.Range("BU2:BU20").SpecialCells(xlConstants)
For Each c In rPatterns
sFilename = Dir(sSrcFolder & "*" & c.Text & "*")
If sFilename = "" Then
c.Interior.ColorIndex = 3
bBad = True
Else
While sFilename <> ""
FileCopy sSrcFolder & sFilename, sTgtFolder & sFilename
sFilename = Dir()
Wend
End If
Next c
MsgBox "File copy completed"