Amend sub to read from names in col A

M

Max

Sub CopynReNameFiles()
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx1.xls"
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx2.xls"
FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\Dxx3.xls"
'etc etc
End Sub

How could the above sub be amended to loop through
& read-in/use all the destination file names, ie:

Dxx1
Dxx2
Dxx3
etc, etc

from the list of 100+ names
that's already placed in col A in the active sheet?

Thanks for insights
 
B

Bob Phillips

Sub CopynReNameFiles()
Dim LastRow As Long
Dim i As Long

With ACtiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow

FileCopy "D:\Max\DBrT.xls", "D:\Max\DBrT\" & .Cells(iI,
"A").Value & ".xls"
Next i
End With
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
B

Bob Phillips

Sorry, typo

Sub CopynReNameFiles()
Dim LastRow As Long
Dim i As Long

With ACtiveSheet

LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow

FileCopy "D:\Max\DBrT.xls", _
"D:\Max\DBrT\" & .Cells(i, "A").Value & ".xls"
Next i
End With
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 

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