Excel help - Find and copy files
Hi Joel,
Thanks for looking into this. I tried and used your code, but I get an error
message (Run-time error '53': File not found). The filenames on the excel
document only contain tif extension. So I am trying to copy and move files
which filenames match ONLY the filenames in my excel document from the files'
directory to a new directory. See below
Sub copyfiles()
OldFolder = "G:\LMG\RECOVERY\AGENCY\Portfolio Sale\2008\A-Program2 Sale
Files\Imaged Copies\Disk1\Disk 1\"
NewFolder = "G:\LMG\RECOVERY\AGENCY\Portfolio Sale\2008\A-Program2 Sale
Files\Imaged Copies\BackUp\"
With Sheets("All")
RowCount = 1
Do While .Range("A" & RowCount) < ""
FName = .Range("A" & RowCount)
FileCopy Source:=OldFolder & FName & ".tif", _
Destination:=NewFolder & FName & ".tif"
RowCount = RowCount + 1
Loop
End With
End Sub
--
Nestor Ike
"Joel" wrote:
The code will look something like the code below. I don't know if the
filenames on the spreadsheet contain the directory or the tif extension.
Modify the code as necessary. Change OldFolder and NewFolder as required.
Sub copyfiles()
OldFolder = "c:\temp\"
NewFolder = "c:\temp\test\"
With Sheets("Sheet1")
RowCount = 1
Do While .Range("A" & RowCount) < ""
FName = .Range("A" & RowCount)
FileCopy Source:=OldFolder & FName & ".tif", _
Destination:=NewFolder & FName & ".tif"
RowCount = RowCount + 1
Loop
End With
End Sub
"Ikenest" wrote:
I need to find file names - from a list in an excel file - that match file
names (with an extension, i.e., 1466319001_20080923193500.tif) located in one
directory folder and save the matched files to a different directory folder.
Thanks,
--
Nestor Ike
|