afzalw
03-08-2013, 09:50 PM
Macro to copy files from one folder to another folder.
All the source paths are in Column A and all destination path are in column B in front of each other (same row).
Source path in column A1 = C:\1.txt
Destination path in Column B1 = C:\a\1.txt
all folders exist no need to create a new folder only copy and paste.
I made this macro but something is wrong its not working.
Thanyou
Sub M20CopyFileandDeletedFolder()
'Create Object
Set fs = CreateObject("Scripting.FileSystemObject")
With ThisWorkbook.Sheets(1)
oldpath = .Range("A2", .Cells(Rows.Count, 1).End(xlUp)).Value
End With
With ThisWorkbook.Sheets(1)
newpath = .Range("B2", .Cells(Rows.Count, 1).End(xlUp)).Value
End With
For i = LBound(oldpath) To UBound(oldpath)
FileCopy oldpath(i, 1), newpath(i, 1)
i = i + 1
Next i
End Sub
All the source paths are in Column A and all destination path are in column B in front of each other (same row).
Source path in column A1 = C:\1.txt
Destination path in Column B1 = C:\a\1.txt
all folders exist no need to create a new folder only copy and paste.
I made this macro but something is wrong its not working.
Thanyou
Sub M20CopyFileandDeletedFolder()
'Create Object
Set fs = CreateObject("Scripting.FileSystemObject")
With ThisWorkbook.Sheets(1)
oldpath = .Range("A2", .Cells(Rows.Count, 1).End(xlUp)).Value
End With
With ThisWorkbook.Sheets(1)
newpath = .Range("B2", .Cells(Rows.Count, 1).End(xlUp)).Value
End With
For i = LBound(oldpath) To UBound(oldpath)
FileCopy oldpath(i, 1), newpath(i, 1)
i = i + 1
Next i
End Sub