How to copy and paste multiple files

E

Ed Dror

Hi there,

I'm using excel 2007 and I wrote

Sub Button1_Click()
FileCopy "C:\Excel\book1.txt" , "C:\Excel\Test\book2.txt"
End Sub

Everything works file but lets assume I have in my spreadsheet two columns

Column A = Source directory looks like this

C:\Source\file1.txt
C:\Source\file2.xls
....
And so on

Column B = Destination looks like this
C:\Destination\file11.txt
C:\Destination\file22.xls
....
And so on

My question is how make the copy and paste function to read the copy and
paste from the spreadsheet itself
Until the end of the list of files

Thanks,
Ed Dror
Andrew Lauren Co.
 
J

Joel

Sub Button1_Click()

RowCount = 1
do while Range("A" & RowCount) <> ""
FileCopy Range("A" & RowCount), Range("B" & RowCount)
RowCount = RowCount + 1
loop
End Sub
 
E

Ed Dror

Joel,

Thank you very much, It works

Ed Dror


Joel said:
Sub Button1_Click()

RowCount = 1
do while Range("A" & RowCount) <> ""
FileCopy Range("A" & RowCount), Range("B" & RowCount)
RowCount = RowCount + 1
loop
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