View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bhupinder Rayat Bhupinder Rayat is offline
external usenet poster
 
Posts: 64
Default Extracting/copying files from a folder using VBA

Tom,

excel doesn't like line 4 (filecopy....), it returns an error message saying
'Application defined or object defined error'.

I double-checked the names and filepaths, which are correct. Any ideas?

Regards,

Bhupinder.

"Tom Ogilvy" wrote:

assume the list of 200 is in column A of the activesheet and the file names
are like a.csv or aaa.csv rather than c:\current\aaa.csv

Sub copysomefiles()
Dim cell as Range
for each cell in Range("A1:A200")
filecopy "c:\current\" & cell.name, "c:\new\ & cell.name"
Next
end Sub

--
Regards,
Tom Ogilvy


"Bhupinder Rayat" wrote in
message ...
Hi all,

I have a folder (i.e. c:\current) that contains around 5000 csv files, and

I
have a list of around 200 off these files that I need to copy and paste to

a
new folder i.e. (c:\new).

Rather than find each file manually or use the search function, is there a
way i can tell vba to search through c:\current for the filenames that I
specify and then copy and paste them to c:\new?

Any help would be much appreciated.

Kind Regards,

Bhupinder.