File Copy Routine

N

Neil

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.
 
T

Tom Ogilvy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top