ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Amend sub to read from names in col A (https://www.excelbanter.com/excel-programming/410007-amend-sub-read-names-col.html)

Max

Amend sub to read from names in col A
 
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



Bob Phillips

Amend sub to read from names in col A
 
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)

"Max" wrote in message
...
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




Bob Phillips

Amend sub to read from names in col A
 
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)

"Bob Phillips" wrote in message
...
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)

"Max" wrote in message
...
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






Max

Amend sub to read from names in col A
 
Many thanks, Bob.
That did it well.

Max




All times are GMT +1. The time now is 11:47 PM.

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