I am trying to move files by the file names in a list and this is the code but didn't work for me and i don't know the reason for not working
Code: Select all
Sub Move_Files()
Dim a As Variant
Dim s As String
Dim t As String
Dim f As String
Dim i As Long
s = ThisWorkbook.Path & "\Source\"
t = ThisWorkbook.Path & "\Target\"
a = Range("A2:B" & Cells(Rows.Count, 1).End(xlUp).Row).Value
On Error Resume Next
For i = 1 To UBound(a, 1)
If a(i, 2) <> "" Then
f = a(i, 1) & ".jpg"
'If Len(Dir(s & f)) Then
FileCopy s & f, t & f
Kill s & f
'End If
' 'If Len(f) * Len(Dir(d & f)) Then
' FileCopy s & f, t & f
' Kill s & f
' 'End If
End If
Next i
On Error GoTo 0
MsgBox "Done...", 64
End Sub