ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help on file and folders Please (https://www.excelbanter.com/excel-programming/296489-help-file-folders-please.html)

Aliandro

Help on file and folders Please
 
Hi I have a list of files in an excel sheet in the first column I would like
to know is there a way I can get excel to search for these files by giving
it a dirctory and then it would copy the files to a directory I set, so say
I have the following in an excel document
15632.dxf
55555.dxf
95854.dxf

now they are under directory X

and the directory I want them to be copier to is XX

is there a way to do this, I would appreciate any help


Thanks.
Ali



Wouter[_2_]

Help on file and folders Please
 
Hi Aliandro,

You need the 'filecopy' command in something like this

Sub CopyThoseFiles()
Dim sFolderFrom As String
Dim sFolderTo As String
Dim sFileName As String
'
sFolderFrom = "X"
sFolderTo = "XX"

Do While Not IsEmpty(ActiveCell)
sFileName = ActiveCell.Value
If Len(Dir(sFolderFrom & "\" & sFileName)) 0 Then
' Only if file existst
FileCopy sFolderFrom & "\" & sFileName, sFolderTo
End If
ActiveCell.Offset(1, 0).Select
Loop


End Sub


GoodLuck,

Woutre HM

"Aliandro" wrote in message ...
Hi I have a list of files in an excel sheet in the first column I would like
to know is there a way I can get excel to search for these files by giving
it a dirctory and then it would copy the files to a directory I set, so say
I have the following in an excel document
15632.dxf
55555.dxf
95854.dxf

now they are under directory X

and the directory I want them to be copier to is XX

is there a way to do this, I would appreciate any help


Thanks.
Ali



All times are GMT +1. The time now is 02:11 AM.

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