This Macro copy path written in Q column to new location path written in R column.
The problem is that it works when I have more than one entries in these Q and R column, but when there is only one entry than it does not work. It gives following error.
Run Time error Type 13
Type mismatched
Thanks
[VBA]
Sub M20CopyExcelFiles()
Set fs = CreateObject("Scripting.FileSystemObject")
With ThisWorkbook.Sheets(2)
LR = .Cells(.Rows.Count, "Q").End(xlUp).Row
oldpath = .Range("Q2:Q" & LR)
newpath = .Range("R2:R" & LR)
End With
For i = LBound(oldpath) To UBound(oldpath)
FileCopy oldpath(i, 1), newpath(i, 1)
Next i
End Sub
[/VBA]