ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   File Copy Routine (https://www.excelbanter.com/excel-programming/271282-file-copy-routine.html)

Neil[_6_]

File Copy Routine
 
Can anyone suggest a little code to do the following.

I will have a list of paths and files starting in cell A1
and going down like this:-
c:\dir\dir\filename.ext
and in column B going down I will have a destination dir
c:\backup\dir\dir\filename.ext

I want to run a loop that moves down column A copying the
files identified in each cell to the location identified
in column B.

Many thanks in advance.

Tom Ogilvy

File Copy Routine
 
Assuming the files are not open:

Sub CopyList()
Dim rng as Range
Dim cell as Range
set rng = Range(Cells(1,1),Cells(rows.count,1).End(xlup))
for each cell in rng
if not( isempty(cell) or isempty(cell.offset(0,1))) then
filecopy cell.value, cell.offset(0,1).value
End if
Next
End Sub

--
Regards,
Tom Ogilvy


"Neil" wrote in message
...
Can anyone suggest a little code to do the following.

I will have a list of paths and files starting in cell A1
and going down like this:-
c:\dir\dir\filename.ext
and in column B going down I will have a destination dir
c:\backup\dir\dir\filename.ext

I want to run a loop that moves down column A copying the
files identified in each cell to the location identified
in column B.

Many thanks in advance.





All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com