Help on file and folders Please

A

Aliandro

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
 
W

Wouter

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
 

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